use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method testBridgesAreDeployed.
@Test
@WithPrometheus
public void testBridgesAreDeployed() throws JsonProcessingException, InterruptedException {
List<BridgeDTO> bridgeDTOS = new ArrayList<>();
bridgeDTOS.add(new BridgeDTO("myId-1", "myName-1", "myEndpoint", TestSupport.CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, TestSupport.KAFKA_CONNECTION_DTO));
bridgeDTOS.add(new BridgeDTO("myId-2", "myName-2", "myEndpoint", TestSupport.CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, TestSupport.KAFKA_CONNECTION_DTO));
stubBridgesToDeployOrDelete(bridgeDTOS);
stubBridgeUpdate();
String expectedJsonUpdateProvisioningRequest = String.format("{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"myEndpoint\", \"customerId\": \"%s\", \"status\": \"provisioning\"}", TestSupport.CUSTOMER_ID);
String expectedJsonUpdateAvailableRequest = String.format("{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"http://192.168.2.49/ob-myid-1\", \"customerId\": \"%s\", \"status\": \"ready\"}", TestSupport.CUSTOMER_ID);
// Four updates to the manager are expected (2 PROVISIONING + 2 READY)
CountDownLatch latch = new CountDownLatch(4);
addBridgeUpdateRequestListener(latch);
managerSyncService.fetchAndProcessBridgesToDeployOrDelete().await().atMost(Duration.ofSeconds(5));
String customerNamespace = customerNamespaceProvider.resolveName(TestSupport.CUSTOMER_ID);
String firstBridgeName = BridgeIngress.resolveResourceName("myId-1");
String secondBridgeName = BridgeIngress.resolveResourceName("myId-2");
Awaitility.await().atMost(Duration.ofMinutes(3)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
kubernetesResourcePatcher.patchReadyDeploymentAsReady(firstBridgeName, customerNamespace);
kubernetesResourcePatcher.patchReadyDeploymentAsReady(secondBridgeName, customerNamespace);
kubernetesResourcePatcher.patchReadyService(firstBridgeName, customerNamespace);
kubernetesResourcePatcher.patchReadyService(secondBridgeName, customerNamespace);
kubernetesResourcePatcher.patchReadyNetworkResource(firstBridgeName, customerNamespace);
kubernetesResourcePatcher.patchReadyNetworkResource(secondBridgeName, customerNamespace);
});
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdateProvisioningRequest, true, true)).withHeader("Content-Type", equalTo("application/json")));
wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdateAvailableRequest, true, true)).withHeader("Content-Type", equalTo("application/json")));
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressTest method fromDTO.
@Test
public void fromDTO() {
BridgeDTO dto = TestSupport.newRequestedBridgeDTO();
BridgeIngress bridgeIngress = BridgeIngress.fromDTO(dto, "ns", "image");
assertThat(bridgeIngress.getMetadata().getNamespace()).isEqualTo("ns");
assertThat(bridgeIngress.getMetadata().getName()).isEqualTo(OB_RESOURCE_NAME_PREFIX + TestSupport.BRIDGE_ID);
assertThat(bridgeIngress.getSpec().getBridgeName()).isEqualTo(dto.getName());
assertThat(bridgeIngress.getSpec().getId()).isEqualTo(dto.getId());
assertThat(bridgeIngress.getSpec().getImage()).isEqualTo("image");
assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(dto.getCustomerId());
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngress method toDTO.
public BridgeDTO toDTO() {
BridgeDTO bridgeDTO = new BridgeDTO();
bridgeDTO.setId(this.getSpec().getId());
bridgeDTO.setCustomerId(this.getSpec().getCustomerId());
bridgeDTO.setName(this.getSpec().getBridgeName());
bridgeDTO.setEndpoint(this.getStatus().getEndpoint());
return bridgeDTO;
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceImpl method toDTO.
@Override
public BridgeDTO toDTO(Bridge bridge) {
KafkaConnectionDTO kafkaConnectionDTO = new KafkaConnectionDTO(internalKafkaConfigurationProvider.getBootstrapServers(), internalKafkaConfigurationProvider.getClientId(), internalKafkaConfigurationProvider.getClientSecret(), internalKafkaConfigurationProvider.getSecurityProtocol(), getBridgeTopicName(bridge));
BridgeDTO dto = new BridgeDTO();
dto.setId(bridge.getId());
dto.setName(bridge.getName());
dto.setEndpoint(bridge.getEndpoint());
dto.setStatus(bridge.getStatus());
dto.setCustomerId(bridge.getCustomerId());
dto.setKafkaConnection(kafkaConnectionDTO);
return dto;
}
Aggregations