use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method updateProcessorStatus.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorStatus() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction()));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
ProcessorDTO processor = processors.get(0);
processor.setStatus(ManagedResourceStatus.READY);
TestUtils.updateProcessor(processor);
processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
assertThat(processors.size()).isZero();
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testGetBridgesToDelete.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDelete() {
TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
List<BridgeDTO> bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isZero();
assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.DEPROVISION)).count()).isEqualTo(1);
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncSegmentationAPITest method testShardSegmentation.
/**
* This test needs to be in a separated class since for the current implementation the ShardService fetches
* the authorized shards at startup. We inject a mock for this scenario.
*/
@Test
@TestSecurity(user = "knative")
public void testShardSegmentation() {
// the bridge gets assigned to the default shard
TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
// The default shard retrieves the bridge to deploy
List<BridgeDTO> bridgesToDeployForDefaultShard = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(bridgesToDeployForDefaultShard.size()).isEqualTo(1);
reset(jwt);
when(jwt.getClaim(APIConstants.SUBJECT_ATTRIBUTE_CLAIM)).thenReturn("knative");
// No bridges are assigned to the 'knative' shard
List<BridgeDTO> bridgesToDeployForOtherShard = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(bridgesToDeployForOtherShard.size()).isEqualTo(0);
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method createAndDeployBridge.
private BridgeResponse createAndDeployBridge() {
BridgeResponse bridgeResponse = createBridge();
BridgeDTO dto = new BridgeDTO();
dto.setId(bridgeResponse.getId());
dto.setStatus(ManagedResourceStatus.READY);
dto.setCustomerId(TestConstants.DEFAULT_CUSTOMER_ID);
dto.setEndpoint("https://foo.bridges.redhat.com");
Response deployment = TestUtils.updateBridge(dto);
assertThat(deployment.getStatusCode()).isEqualTo(200);
return bridgeResponse;
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ExecutorServiceTest method before.
@BeforeEach
public void before() {
executor = mock(Executor.class);
BridgeDTO bridgeDTO = mock(BridgeDTO.class);
when(bridgeDTO.getId()).thenReturn(BRIDGE_ID);
ProcessorDTO processorDTO = mock(ProcessorDTO.class);
when(processorDTO.getBridgeId()).thenReturn(BRIDGE_ID);
when(executor.getProcessor()).thenReturn(processorDTO);
when(executorsProvider.getExecutor()).thenReturn(executor);
}
Aggregations