use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceTest method testUpdateBridgeStatusReadyPublishedAt.
@Test
public void testUpdateBridgeStatusReadyPublishedAt() {
BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
Bridge bridge = bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
bridge.setStatus(ManagedResourceStatus.PROVISIONING);
bridgesService.updateBridge(bridgesService.toDTO(bridge));
Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(retrievedBridge.getStatus()).isEqualTo(ManagedResourceStatus.PROVISIONING);
assertThat(retrievedBridge.getPublishedAt()).isNull();
// Once ready it should have its published date set
bridge.setStatus(ManagedResourceStatus.READY);
bridgesService.updateBridge(bridgesService.toDTO(bridge));
Bridge publishedBridge = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(publishedBridge.getStatus()).isEqualTo(ManagedResourceStatus.READY);
ZonedDateTime publishedAt = publishedBridge.getPublishedAt();
assertThat(publishedAt).isNotNull();
// Check calls to set PublishedAt at idempotent
bridgesService.updateBridge(bridgesService.toDTO(bridge));
Bridge publishedBridge2 = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(publishedBridge2.getStatus()).isEqualTo(ManagedResourceStatus.READY);
assertThat(publishedBridge2.getPublishedAt()).isEqualTo(publishedAt);
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceTest method testGetBridges.
@Test
public void testGetBridges() {
BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
ListResult<Bridge> bridges = bridgesService.getBridges(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
assertThat(bridges.getSize()).isEqualTo(1);
assertThat(bridges.getTotal()).isEqualTo(1);
assertThat(bridges.getPage()).isZero();
// filter by customer id not implemented yet
bridges = bridgesService.getBridges("not-the-id", new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
assertThat(bridges.getSize()).isZero();
assertThat(bridges.getTotal()).isZero();
assertThat(bridges.getPage()).isZero();
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceTest method testCreateBridge.
@Test
public void testCreateBridge() {
BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
List<Bridge> bridgesToDeploy = bridgesService.getBridgesByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.ACCEPTED), TestConstants.SHARD_ID);
assertThat(bridgesToDeploy.size()).isEqualTo(1);
assertThat(bridgesToDeploy.get(0).getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(bridgesToDeploy.get(0).getEndpoint()).isNull();
ListResult<Bridge> bridges = bridgesService.getBridges(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
assertThat(bridges.getSize()).isEqualTo(1);
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testDeleteProcessor.
@Test
public void testDeleteProcessor() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
await().atMost(5, SECONDS).untilAsserted(() -> {
Processor p = processorDAO.findById(processor.getId());
assertThat(p).isNotNull();
assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
});
processorService.deleteProcessor(b.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
await().atMost(5, SECONDS).untilAsserted(() -> {
Processor p = processorDAO.findById(processor.getId());
assertThat(p).isNotNull();
assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.DELETED);
assertThat(p.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
assertShardAsksForProcessorToBeDeletedIncludes(processor);
});
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method createProcessor_bridgeNotActive.
@Test
public void createProcessor_bridgeNotActive() {
Bridge b = createPersistBridge(ManagedResourceStatus.PROVISIONING);
assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> processorService.createProcessor(b.getId(), b.getCustomerId(), new ProcessorRequest()));
}
Aggregations