use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceImpl method convert.
InstallationEntity convert(Installation installation) {
InstallationEntity result = new InstallationEntity();
result.setId(installation.getId());
result.setCockpitURL(this.cockpitURL);
result.setCreatedAt(installation.getCreatedAt());
result.setUpdatedAt(installation.getUpdatedAt());
result.setAdditionalInformation(installation.getAdditionalInformation());
return result;
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceTest method shouldGetInstallation.
@Test
public void shouldGetInstallation() throws TechnicalException {
final InstallationEntity installationEntity = installationService.get();
verify(installationRepository).find();
assertNotNull(installationEntity);
assertEquals(INSTALLATION_ID, installationEntity.getId());
assertEquals(NOW, installationEntity.getCreatedAt());
assertEquals(NOW, installationEntity.getUpdatedAt());
assertEquals(2, installationEntity.getAdditionalInformation().size());
assertEquals(COCKPIT_INSTALLATION_ID, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_ID));
assertEquals(COCKPIT_INSTALLATION_STATUS, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_STATUS));
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class ListEnvironmentOperationHandlerTest method before.
@Before
public void before() {
cut = new ListEnvironmentOperationHandler(environmentService, installationService, objectMapper);
installationEntity = new InstallationEntity();
installationEntity.setId(INSTALLATION_ID);
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class PromoteApiOperationHandlerTest method shouldHandlePromotionRequest.
@Test
public void shouldHandlePromotionRequest() throws JsonProcessingException {
BridgeCommand command = new BridgeCommand();
command.setOperation(BridgeOperation.PROMOTE_API.name());
command.setId(COMMAND_ID);
command.setInstallationId(INSTALLATION_ID);
command.setOrganizationId(ORGANIZATION_ID);
command.setEnvironmentId(ENVIRONMENT_ID);
command.setPayload(new BridgePayload());
final BridgeTarget bridgeTarget = new BridgeTarget();
bridgeTarget.setEnvironmentId("target");
command.setTarget(bridgeTarget);
ArgumentCaptor<PromotionEntity> argument = ArgumentCaptor.forClass(PromotionEntity.class);
when(objectMapper.readValue(command.getPayload().getContent(), PromotionEntity.class)).thenReturn(getAPromotionEntity());
InstallationEntity installationEntity = new InstallationEntity();
installationEntity.setId(INSTALLATION_ID);
when(installationService.get()).thenReturn(installationEntity);
TestObserver<BridgeReply> obs = cut.handle(command).test();
verify(promotionService, times(1)).createOrUpdate(argument.capture());
Assertions.assertThat(argument.getValue().getStatus()).isEqualTo(PromotionEntityStatus.TO_BE_VALIDATED);
obs.awaitTerminalEvent();
obs.assertValue(reply -> {
BridgeSimpleReply simpleReply = (BridgeSimpleReply) reply;
return (simpleReply.getCommandStatus().equals(CommandStatus.SUCCEEDED) && simpleReply.getOrganizationId().equals(ORGANIZATION_ID) && simpleReply.getEnvironmentId().equals("target") && simpleReply.getInstallationId().equals(INSTALLATION_ID) && simpleReply.getCommandId().equals(COMMAND_ID));
});
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class GoodbyeCommandHandlerTest method handle.
@Test
public void handle() {
final InstallationEntity installation = new InstallationEntity();
installation.setId(INSTALLATION_ID);
installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
GoodbyeCommand command = new GoodbyeCommand();
when(installationService.getOrInitialize()).thenReturn(installation);
when(promotionService.search(any(), any(), any())).thenReturn(new Page<>(emptyList(), 0, 0, 0));
TestObserver<GoodbyeReply> obs = cut.handle(command).test();
obs.awaitTerminalEvent();
obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.SUCCEEDED));
final HashMap<String, String> expectedAdditionalInfos = new HashMap<>();
expectedAdditionalInfos.put(CUSTOM_KEY, CUSTOM_VALUE);
expectedAdditionalInfos.put(InstallationService.COCKPIT_INSTALLATION_STATUS, DELETED_STATUS);
verify(installationService, times(1)).setAdditionalInformation(expectedAdditionalInfos);
}
Aggregations