Search in sources :

Example 31 with Service

use of com.google.monitoring.v3.Service in project yakc by manusa.

the class ServiceLegacyIT method patchNamespacedService.

@Test
@DisplayName("patchNamespacedService, should patch labels of Service")
void patchNamespacedService() throws IOException {
    // When
    final Service result = KC.create(CoreV1Api.class).patchNamespacedService(serviceName, NAMESPACE, Service.builder().metadata(ObjectMeta.builder().putInLabels("patched", "label").build()).build()).get();
    // Then
    assertThat(result).isNotNull().extracting(Service::getMetadata).hasFieldOrPropertyWithValue("name", serviceName).extracting(ObjectMeta::getLabels).asInstanceOf(InstanceOfAssertFactories.MAP).hasSize(2).containsEntry("patched", "label");
}
Also used : Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 32 with Service

use of com.google.monitoring.v3.Service in project yakc by manusa.

the class ServiceLegacyIT method replaceNamespacedService.

@Test
@DisplayName("replaceNamespacedService, should replace existing Service's port")
void replaceNamespacedService() throws IOException {
    // Given
    final Service existingService = KC.create(CoreV1Api.class).readNamespacedService(serviceName, NAMESPACE).get();
    existingService.getSpec().getPorts().get(0).setTargetPort("http");
    // When
    final Service result = KC.create(CoreV1Api.class).replaceNamespacedService(serviceName, NAMESPACE, existingService).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("metadata.name", serviceName).extracting(Service::getSpec).extracting(ServiceSpec::getPorts).asList().hasSize(2).element(0).hasFieldOrPropertyWithValue("targetPort", "http");
}
Also used : ServiceSpec(com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec) Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 33 with Service

use of com.google.monitoring.v3.Service in project dekorate by dekorateio.

the class Feat458Test method shouldHaveKubernetestLabelsKnativeYml.

@Test
public void shouldHaveKubernetestLabelsKnativeYml() {
    KubernetesList list = Serialization.unmarshalAsList(Feat458Test.class.getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
    assertNotNull(list);
    Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
    assertNotNull(s);
    Map<String, String> labels = s.getMetadata().getLabels();
    assertNotNull(labels);
    assertTrue(labels.containsKey(Labels.NAME));
    assertTrue(labels.containsKey(Labels.VERSION));
    assertFalse(labels.containsKey(OpenshiftLabels.RUNTIME));
    Map<String, String> annotations = s.getMetadata().getAnnotations();
    assertNotNull(annotations);
    assertTrue(annotations.containsKey(Annotations.COMMIT_ID));
    assertFalse(annotations.containsKey(OpenshiftAnnotations.VCS_URL));
    assertTrue(annotations.containsKey(Annotations.VCS_URL));
}
Also used : Service(io.fabric8.knative.serving.v1.Service) Test(org.junit.jupiter.api.Test)

Example 34 with Service

use of com.google.monitoring.v3.Service in project dekorate by dekorateio.

the class KnativeManifestGenerator method generate.

public void generate(KnativeConfig config) {
    Optional<Service> existingService = resourceRegistry.groups().getOrDefault(KNATIVE, new KubernetesListBuilder()).buildItems().stream().filter(i -> i instanceof Service).map(i -> (Service) i).filter(i -> i.getMetadata().getName().equals(config.getName())).findAny();
    if (!existingService.isPresent()) {
        resourceRegistry.add(KNATIVE, createService(config));
    }
    Project project = getProject();
    Optional<VcsConfig> vcsConfig = configurationRegistry.get(VcsConfig.class);
    String remote = vcsConfig.map(VcsConfig::getRemote).orElse(Git.ORIGIN);
    boolean httpsPrefered = vcsConfig.map(VcsConfig::isHttpsPreferred).orElse(false);
    String vcsUrl = project.getScmInfo() != null && Strings.isNotNullOrEmpty(project.getScmInfo().getRemote().get(Git.ORIGIN)) ? Git.getRemoteUrl(project.getRoot(), remote, httpsPrefered).orElse(Labels.UNKNOWN) : Labels.UNKNOWN;
    resourceRegistry.decorate(KNATIVE, new AddVcsUrlAnnotationDecorator(config.getName(), Annotations.VCS_URL, vcsUrl));
    resourceRegistry.decorate(KNATIVE, new AddCommitIdAnnotationDecorator());
    resourceRegistry.decorate(KNATIVE, new ApplyPortNameDecorator(null, null, config.getHttpTransportVersion() != null ? config.getHttpTransportVersion().name().toLowerCase() : "http1", Ports.webPortNames().toArray(new String[Ports.webPortNames().size()])));
    addDecorators(KNATIVE, config);
    if (config.getMinScale() != null && config.getMinScale() != 0) {
        resourceRegistry.decorate(KNATIVE, new ApplyMinScaleDecorator(config.getName(), config.getMinScale()));
    }
    if (config.getMaxScale() != null && config.getMaxScale() != 0) {
        resourceRegistry.decorate(KNATIVE, new ApplyMaxScaleDecorator(config.getName(), config.getMaxScale()));
    }
    if (!config.isScaleToZeroEnabled()) {
        resourceRegistry.decorate(KNATIVE, new AddConfigMapResourceProvidingDecorator("config-autoscaler"));
        resourceRegistry.decorate(KNATIVE, new AddConfigMapDataDecorator("config-autoscaler", "enable-scale-to-zero", String.valueOf(config.isAutoDeployEnabled())));
    }
    if (Strings.isNotNullOrEmpty(config.getRevisionName())) {
        resourceRegistry.decorate(KNATIVE, new ApplyRevisionNameDecorator(config.getName(), config.getRevisionName()));
    }
    if (config.getRevisionAutoScaling() != null) {
        if (config.getRevisionAutoScaling().getMetric() != null && config.getRevisionAutoScaling().getMetric() != AutoscalingMetric.concurrency) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalAutoscalingMetricDecorator(config.getName(), config.getRevisionAutoScaling().getMetric()));
        }
        if (config.getRevisionAutoScaling().getContainerConcurrency() != null) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalContainerConcurrencyDecorator(config.getName(), config.getRevisionAutoScaling().getContainerConcurrency()));
        }
        // Local autoscaling configuration
        if (config.getRevisionAutoScaling().getAutoScalerClass() != null && config.getRevisionAutoScaling().getAutoScalerClass() != AutoScalerClass.kpa) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalAutoscalingClassDecorator(config.getName(), config.getRevisionAutoScaling().getAutoScalerClass()));
        }
        if (config.getRevisionAutoScaling().getTarget() != null && config.getRevisionAutoScaling().getTarget() != 0) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalAutoscalingTargetDecorator(config.getName(), config.getRevisionAutoScaling().getTarget()));
        }
        if (config.getRevisionAutoScaling().getTarget() != null && config.getRevisionAutoScaling().getTarget() != 200 && config.getRevisionAutoScaling().getMetric() == AutoscalingMetric.rps) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalContainerConcurrencyDecorator(config.getName(), config.getRevisionAutoScaling().getTarget()));
        }
        if (config.getRevisionAutoScaling().getTargetUtilizationPercentage() != null && config.getRevisionAutoScaling().getTargetUtilizationPercentage() != 70) {
            resourceRegistry.decorate(KNATIVE, new ApplyLocalContainerConcurrencyDecorator(config.getName(), config.getRevisionAutoScaling().getTargetUtilizationPercentage()));
        }
    }
    // Global autoscaling configuration
    if (config.getGlobalAutoScaling() != null) {
        if (!isDefault(config.getGlobalAutoScaling())) {
            resourceRegistry.decorate(KNATIVE, new AddConfigMapResourceProvidingDecorator("config-autoscaler"));
            if (config.getGlobalAutoScaling().getAutoScalerClass() != null && config.getGlobalAutoScaling().getAutoScalerClass() != AutoScalerClass.kpa) {
                resourceRegistry.decorate(KNATIVE, new ApplyGlobalAutoscalingClassDecorator(config.getGlobalAutoScaling().getAutoScalerClass()));
            }
            if (config.getGlobalAutoScaling().getRequestsPerSecond() != null && config.getGlobalAutoScaling().getRequestsPerSecond() != 200) {
                resourceRegistry.decorate(KNATIVE, new ApplyGlobalRequestsPerSecondTargetDecorator(config.getGlobalAutoScaling().getRequestsPerSecond()));
            }
            if (config.getGlobalAutoScaling().getTargetUtilizationPercentage() != null && config.getGlobalAutoScaling().getTargetUtilizationPercentage() != 70) {
                resourceRegistry.decorate(KNATIVE, new ApplyGlobalContainerConcurrencyDecorator(config.getGlobalAutoScaling().getTargetUtilizationPercentage()));
            }
        }
        if (config.getGlobalAutoScaling().getContainerConcurrency() != null && config.getGlobalAutoScaling().getContainerConcurrency() != 0) {
            resourceRegistry.decorate(KNATIVE, new AddConfigMapResourceProvidingDecorator("config-defaults"));
            resourceRegistry.decorate(KNATIVE, new ApplyGlobalContainerConcurrencyDecorator(config.getGlobalAutoScaling().getContainerConcurrency()));
        }
    }
    for (Traffic traffic : config.getTraffic()) {
        String revisionName = Strings.isNotNullOrEmpty(config.getRevisionName()) ? config.getRevisionName() : null;
        String tag = Strings.isNotNullOrEmpty(traffic.getTag()) ? traffic.getTag() : null;
        boolean latestRevision = revisionName == null ? true : traffic.isLatestRevision();
        long percentage = traffic.getPercentage();
        resourceRegistry.decorate(KNATIVE, new ApplyTrafficDecorator(config.getName(), revisionName, latestRevision, percentage, tag));
    }
    // Revision specific stuff
    for (Container container : config.getSidecars()) {
        resourceRegistry.decorate(KNATIVE, new AddSidecarToRevisionDecorator(config.getName(), container));
    }
    for (SecretVolume volume : config.getSecretVolumes()) {
        validateVolume(volume);
        resourceRegistry.decorate(KNATIVE, new AddSecretVolumeToRevisionDecorator(volume));
    }
    for (ConfigMapVolume volume : config.getConfigMapVolumes()) {
        validateVolume(volume);
        resourceRegistry.decorate(KNATIVE, new AddConfigMapVolumeToRevisionDecorator(volume));
    }
    for (PersistentVolumeClaimVolume volume : config.getPvcVolumes()) {
        resourceRegistry.decorate(KNATIVE, new AddPvcVolumeToRevisionDecorator(volume));
    }
    for (AzureFileVolume volume : config.getAzureFileVolumes()) {
        resourceRegistry.decorate(KNATIVE, new AddAzureFileVolumeToRevisionDecorator(volume));
    }
    for (AzureDiskVolume volume : config.getAzureDiskVolumes()) {
        resourceRegistry.decorate(KNATIVE, new AddAzureDiskVolumeToRevisionDecorator(volume));
    }
    for (AwsElasticBlockStoreVolume volume : config.getAwsElasticBlockStoreVolumes()) {
        resourceRegistry.decorate(KNATIVE, new AddAwsElasticBlockStoreVolumeToRevisionDecorator(volume));
    }
    for (HostAlias hostAlias : config.getHostAliases()) {
        resourceRegistry.decorate(KNATIVE, new AddHostAliasesToRevisionDecorator(hostAlias));
    }
}
Also used : WithProject(io.dekorate.WithProject) Strings(io.dekorate.utils.Strings) LabelBuilder(io.dekorate.kubernetes.config.LabelBuilder) Project(io.dekorate.project.Project) ApplyMinScaleDecorator(io.dekorate.knative.decorator.ApplyMinScaleDecorator) KnativeConfigBuilder(io.dekorate.knative.config.KnativeConfigBuilder) AddAzureFileVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAzureFileVolumeToRevisionDecorator) EditableKnativeConfig(io.dekorate.knative.config.EditableKnativeConfig) AddVcsUrlAnnotationDecorator(io.dekorate.kubernetes.decorator.AddVcsUrlAnnotationDecorator) ApplyDeployToApplicationConfiguration(io.dekorate.kubernetes.configurator.ApplyDeployToApplicationConfiguration) AddSidecarToRevisionDecorator(io.dekorate.knative.decorator.AddSidecarToRevisionDecorator) AzureDiskVolume(io.dekorate.kubernetes.config.AzureDiskVolume) SecretVolume(io.dekorate.kubernetes.config.SecretVolume) AutoScalerClass(io.dekorate.knative.config.AutoScalerClass) AddConfigMapVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator) ApplyLocalAutoscalingClassDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingClassDecorator) ApplyPortNameDecorator(io.dekorate.kubernetes.decorator.ApplyPortNameDecorator) AddLabelDecorator(io.dekorate.kubernetes.decorator.AddLabelDecorator) HostAlias(io.dekorate.kubernetes.config.HostAlias) ApplyLocalAutoscalingTargetDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingTargetDecorator) Configuration(io.dekorate.kubernetes.config.Configuration) ConfigurationRegistry(io.dekorate.ConfigurationRegistry) KnativeConfig(io.dekorate.knative.config.KnativeConfig) ApplyTrafficDecorator(io.dekorate.knative.decorator.ApplyTrafficDecorator) VcsConfig(io.dekorate.option.config.VcsConfig) ApplyLocalAutoscalingMetricDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingMetricDecorator) AddConfigMapResourceProvidingDecorator(io.dekorate.kubernetes.decorator.AddConfigMapResourceProvidingDecorator) Traffic(io.dekorate.knative.config.Traffic) Ports(io.dekorate.utils.Ports) AutoscalingMetric(io.dekorate.knative.config.AutoscalingMetric) ApplyMaxScaleDecorator(io.dekorate.knative.decorator.ApplyMaxScaleDecorator) ApplyRevisionNameDecorator(io.dekorate.knative.decorator.ApplyRevisionNameDecorator) AddAwsElasticBlockStoreVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAwsElasticBlockStoreVolumeToRevisionDecorator) AddHostAliasesToRevisionDecorator(io.dekorate.knative.decorator.AddHostAliasesToRevisionDecorator) ResourceRegistry(io.dekorate.ResourceRegistry) ApplyLocalContainerConcurrencyDecorator(io.dekorate.knative.decorator.ApplyLocalContainerConcurrencyDecorator) Optional(java.util.Optional) AzureFileVolume(io.dekorate.kubernetes.config.AzureFileVolume) ApplyGlobalContainerConcurrencyDecorator(io.dekorate.knative.decorator.ApplyGlobalContainerConcurrencyDecorator) Images(io.dekorate.utils.Images) Service(io.fabric8.knative.serving.v1.Service) AbstractKubernetesManifestGenerator(io.dekorate.AbstractKubernetesManifestGenerator) ConfigMapVolume(io.dekorate.kubernetes.config.ConfigMapVolume) ApplyProjectInfo(io.dekorate.project.ApplyProjectInfo) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Labels(io.dekorate.utils.Labels) PersistentVolumeClaimVolume(io.dekorate.kubernetes.config.PersistentVolumeClaimVolume) ConfigurationSupplier(io.dekorate.config.ConfigurationSupplier) ApplyGlobalAutoscalingClassDecorator(io.dekorate.knative.decorator.ApplyGlobalAutoscalingClassDecorator) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Annotations(io.dekorate.utils.Annotations) AddConfigMapDataDecorator(io.dekorate.kubernetes.decorator.AddConfigMapDataDecorator) AddPvcVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddPvcVolumeToRevisionDecorator) BuildServiceFactories(io.dekorate.BuildServiceFactories) GlobalAutoScaling(io.dekorate.knative.config.GlobalAutoScaling) AwsElasticBlockStoreVolume(io.dekorate.kubernetes.config.AwsElasticBlockStoreVolume) AddSecretVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator) ImageConfigurationBuilder(io.dekorate.kubernetes.config.ImageConfigurationBuilder) Container(io.dekorate.kubernetes.config.Container) ImageConfiguration(io.dekorate.kubernetes.config.ImageConfiguration) AddAzureDiskVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAzureDiskVolumeToRevisionDecorator) AddCommitIdAnnotationDecorator(io.dekorate.kubernetes.decorator.AddCommitIdAnnotationDecorator) Git(io.dekorate.utils.Git) ApplyGlobalRequestsPerSecondTargetDecorator(io.dekorate.knative.decorator.ApplyGlobalRequestsPerSecondTargetDecorator) AddConfigMapVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddConfigMapVolumeToRevisionDecorator) AzureDiskVolume(io.dekorate.kubernetes.config.AzureDiskVolume) PersistentVolumeClaimVolume(io.dekorate.kubernetes.config.PersistentVolumeClaimVolume) AddAzureDiskVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAzureDiskVolumeToRevisionDecorator) ApplyGlobalContainerConcurrencyDecorator(io.dekorate.knative.decorator.ApplyGlobalContainerConcurrencyDecorator) Traffic(io.dekorate.knative.config.Traffic) AddSidecarToRevisionDecorator(io.dekorate.knative.decorator.AddSidecarToRevisionDecorator) VcsConfig(io.dekorate.option.config.VcsConfig) ApplyPortNameDecorator(io.dekorate.kubernetes.decorator.ApplyPortNameDecorator) AddConfigMapDataDecorator(io.dekorate.kubernetes.decorator.AddConfigMapDataDecorator) ApplyRevisionNameDecorator(io.dekorate.knative.decorator.ApplyRevisionNameDecorator) AddConfigMapResourceProvidingDecorator(io.dekorate.kubernetes.decorator.AddConfigMapResourceProvidingDecorator) ApplyLocalAutoscalingMetricDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingMetricDecorator) AddPvcVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddPvcVolumeToRevisionDecorator) Container(io.dekorate.kubernetes.config.Container) AddCommitIdAnnotationDecorator(io.dekorate.kubernetes.decorator.AddCommitIdAnnotationDecorator) ApplyTrafficDecorator(io.dekorate.knative.decorator.ApplyTrafficDecorator) AddAzureFileVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAzureFileVolumeToRevisionDecorator) ApplyMaxScaleDecorator(io.dekorate.knative.decorator.ApplyMaxScaleDecorator) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ApplyLocalAutoscalingTargetDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingTargetDecorator) AwsElasticBlockStoreVolume(io.dekorate.kubernetes.config.AwsElasticBlockStoreVolume) ApplyLocalContainerConcurrencyDecorator(io.dekorate.knative.decorator.ApplyLocalContainerConcurrencyDecorator) ConfigMapVolume(io.dekorate.kubernetes.config.ConfigMapVolume) AddSecretVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddSecretVolumeToRevisionDecorator) ApplyGlobalAutoscalingClassDecorator(io.dekorate.knative.decorator.ApplyGlobalAutoscalingClassDecorator) SecretVolume(io.dekorate.kubernetes.config.SecretVolume) AddHostAliasesToRevisionDecorator(io.dekorate.knative.decorator.AddHostAliasesToRevisionDecorator) Service(io.fabric8.knative.serving.v1.Service) AddVcsUrlAnnotationDecorator(io.dekorate.kubernetes.decorator.AddVcsUrlAnnotationDecorator) ApplyLocalAutoscalingClassDecorator(io.dekorate.knative.decorator.ApplyLocalAutoscalingClassDecorator) ApplyMinScaleDecorator(io.dekorate.knative.decorator.ApplyMinScaleDecorator) AzureFileVolume(io.dekorate.kubernetes.config.AzureFileVolume) HostAlias(io.dekorate.kubernetes.config.HostAlias) WithProject(io.dekorate.WithProject) Project(io.dekorate.project.Project) ApplyGlobalRequestsPerSecondTargetDecorator(io.dekorate.knative.decorator.ApplyGlobalRequestsPerSecondTargetDecorator) AddAwsElasticBlockStoreVolumeToRevisionDecorator(io.dekorate.knative.decorator.AddAwsElasticBlockStoreVolumeToRevisionDecorator)

Example 35 with Service

use of com.google.monitoring.v3.Service in project Oxalis-AS4 by OxalisCommunity.

the class AbstractMessagingProviderTest method testCreateMessagingHeader.

@Test
public void testCreateMessagingHeader() throws Exception {
    TransmissionRequestFactory transmissionRequestFactory = new TransmissionRequestFactory(new NoopContentDetector(), new NoopContentWrapper(), new NoopTagGenerator(), new SbdhHeaderParser(), NoopTracerFactory.create());
    TransmissionMessage transmissionMessage;
    try (InputStream inputStream = getClass().getResourceAsStream(getPayloadPath())) {
        transmissionMessage = transmissionRequestFactory.newInstance(inputStream);
    }
    Assert.assertNotNull(transmissionMessage.getHeader());
    TransmissionRequest transmissionRequest = new DefaultTransmissionRequestFacade(transmissionMessage, Endpoint.of(TransportProfile.PEPPOL_AS2_2_0, null, receiverCert));
    HashMap<String, List<String>> headers = new HashMap<>();
    headers.put(Content_ID_KEY, Collections.singletonList(Content_ID_VALUE));
    headers.put(COMPRESSION_TYPE_KEY, Collections.singletonList(COMPRESSION_TYPE_VALUE));
    headers.put(MIME_TYPE_KEY, Collections.singletonList(MIME_TYPE_VALUE));
    Attachment attachment = AttachmentUtil.createAttachment(transmissionRequest.getPayload(), headers);
    Messaging messaging = messagingProvider.createMessagingHeader(transmissionRequest, new ArrayList<>(Collections.singletonList(attachment)));
    UserMessage userMessage = messaging.getUserMessage().get(0);
    // MessageInfo
    XMLGregorianCalendar timestamp = userMessage.getMessageInfo().getTimestamp();
    String messageId = userMessage.getMessageInfo().getMessageId();
    Assert.assertNotNull(timestamp);
    Assert.assertNotNull(messageId);
    // PartyInfo
    String to = userMessage.getPartyInfo().getTo().getPartyId().get(0).getValue();
    String toType = userMessage.getPartyInfo().getTo().getPartyId().get(0).getType();
    String toRole = userMessage.getPartyInfo().getTo().getRole();
    String from = userMessage.getPartyInfo().getFrom().getPartyId().get(0).getValue();
    String fromType = userMessage.getPartyInfo().getFrom().getPartyId().get(0).getType();
    String fromRole = userMessage.getPartyInfo().getFrom().getRole();
    Assert.assertEquals(to, RECEIVER);
    Assert.assertEquals(toType, PARTY_TYPE);
    Assert.assertEquals(toRole, TO_ROLE);
    Assert.assertEquals(from, SENDER);
    Assert.assertEquals(fromType, PARTY_TYPE);
    Assert.assertEquals(fromRole, FROM_ROLE);
    // CollaborationInfo
    String action = userMessage.getCollaborationInfo().getAction();
    Service service = userMessage.getCollaborationInfo().getService();
    String conversationId = userMessage.getCollaborationInfo().getConversationId();
    Assert.assertEquals(action, ACTION);
    Assert.assertEquals(service.getType(), SERVICE_TYPE);
    Assert.assertEquals(service.getValue(), SERVICE_VALUE);
    Assert.assertNotNull(conversationId);
    // MessageProperties
    String finalRecipient = userMessage.getMessageProperties().getProperty().stream().filter(p -> "finalRecipient".equalsIgnoreCase(p.getName())).map(Property::getValue).findFirst().get();
    String originalSender = userMessage.getMessageProperties().getProperty().stream().filter(p -> "originalSender".equalsIgnoreCase(p.getName())).map(Property::getValue).findFirst().get();
    Assert.assertEquals(finalRecipient, FINAL_RECIPIENT);
    Assert.assertEquals(originalSender, ORIGINAL_SENDER);
    // PayloadInfo
    int payloadCount = userMessage.getPayloadInfo().getPartInfo().size();
    Assert.assertEquals(payloadCount, 1);
    List<Property> partInfo = userMessage.getPayloadInfo().getPartInfo().get(0).getPartProperties().getProperty();
    String compressionType = partInfo.stream().filter(pi -> COMPRESSION_TYPE_KEY.equalsIgnoreCase(pi.getName())).map(Property::getValue).findFirst().get();
    String mimeType = partInfo.stream().filter(pi -> MIME_TYPE_KEY.equalsIgnoreCase(pi.getName())).map(Property::getValue).findFirst().get();
    String contentID = userMessage.getPayloadInfo().getPartInfo().get(0).getHref();
    Assert.assertEquals(compressionType, COMPRESSION_TYPE_VALUE);
    Assert.assertEquals(mimeType, MIME_TYPE_VALUE);
    Assert.assertEquals(contentID, "cid:" + Content_ID_VALUE);
}
Also used : X509Certificate(java.security.cert.X509Certificate) KeyPair(java.security.KeyPair) DefaultTransmissionRequestFacade(network.oxalis.outbound.transmission.DefaultTransmissionRequestFacade) java.util(java.util) ContentSigner(org.bouncycastle.operator.ContentSigner) JcaX509CertificateConverter(org.bouncycastle.cert.jcajce.JcaX509CertificateConverter) JcaContentSignerBuilder(org.bouncycastle.operator.jcajce.JcaContentSignerBuilder) Test(org.testng.annotations.Test) Endpoint(network.oxalis.vefa.peppol.common.model.Endpoint) Attachment(org.apache.cxf.message.Attachment) X500Name(org.bouncycastle.asn1.x500.X500Name) Assert(org.testng.Assert) TransmissionRequestFactory(network.oxalis.outbound.transmission.TransmissionRequestFactory) BigInteger(java.math.BigInteger) TransmissionMessage(network.oxalis.api.outbound.TransmissionMessage) TransportProfile(network.oxalis.vefa.peppol.common.model.TransportProfile) KeyPairGenerator(java.security.KeyPairGenerator) NoopContentDetector(network.oxalis.commons.transformer.NoopContentDetector) NoopTracerFactory(io.opentracing.noop.NoopTracerFactory) JcaX509v3CertificateBuilder(org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder) BeforeClass(org.testng.annotations.BeforeClass) TransmissionRequest(network.oxalis.api.outbound.TransmissionRequest) SbdhHeaderParser(network.oxalis.commons.header.SbdhHeaderParser) Messaging(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Messaging) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DefaultMessageIdGenerator(network.oxalis.as4.common.DefaultMessageIdGenerator) MessagingProviderFacade(network.oxalis.outbound.transmission.MessagingProviderFacade) NoopContentWrapper(network.oxalis.commons.transformer.NoopContentWrapper) AttachmentUtil(org.apache.cxf.attachment.AttachmentUtil) UserMessage(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.UserMessage) Property(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Property) Service(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Service) NoopTagGenerator(network.oxalis.commons.tag.NoopTagGenerator) PeppolConfiguration(network.oxalis.as4.util.PeppolConfiguration) InputStream(java.io.InputStream) TransmissionMessage(network.oxalis.api.outbound.TransmissionMessage) NoopTagGenerator(network.oxalis.commons.tag.NoopTagGenerator) InputStream(java.io.InputStream) Service(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Service) Attachment(org.apache.cxf.message.Attachment) UserMessage(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.UserMessage) SbdhHeaderParser(network.oxalis.commons.header.SbdhHeaderParser) Endpoint(network.oxalis.vefa.peppol.common.model.Endpoint) TransmissionRequest(network.oxalis.api.outbound.TransmissionRequest) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) NoopContentWrapper(network.oxalis.commons.transformer.NoopContentWrapper) Messaging(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Messaging) NoopContentDetector(network.oxalis.commons.transformer.NoopContentDetector) Property(org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Property) TransmissionRequestFactory(network.oxalis.outbound.transmission.TransmissionRequestFactory) DefaultTransmissionRequestFacade(network.oxalis.outbound.transmission.DefaultTransmissionRequestFacade) Test(org.testng.annotations.Test)

Aggregations

Test (org.junit.jupiter.api.Test)33 Test (org.junit.Test)30 Service (io.fabric8.knative.serving.v1.Service)28 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 AbstractMessage (com.google.protobuf.AbstractMessage)19 CoreException (org.eclipse.core.runtime.CoreException)18 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)16 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)16 HashMap (java.util.HashMap)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 ArrayList (java.util.ArrayList)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 StatusRuntimeException (io.grpc.StatusRuntimeException)11 ProdBuildResults (io.quarkus.test.ProdBuildResults)11 ProdModeTestResults (io.quarkus.test.ProdModeTestResults)11 QuarkusProdModeTest (io.quarkus.test.QuarkusProdModeTest)11 Path (java.nio.file.Path)11