use of io.gravitee.cockpit.api.command.goodbye.GoodbyeCommand in project gravitee-management-rest-api by gravitee-io.
the class GoodbyeCommandHandlerTest method handleWithException.
@Test
public void handleWithException() {
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(installationService.setAdditionalInformation(anyMap())).thenThrow(new TechnicalManagementException());
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.ERROR));
}
use of io.gravitee.cockpit.api.command.goodbye.GoodbyeCommand 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);
}
use of io.gravitee.cockpit.api.command.goodbye.GoodbyeCommand in project gravitee-management-rest-api by gravitee-io.
the class GoodbyeCommandHandlerTest method handleRejectAllPromotionToValidate.
@Test
public void handleRejectAllPromotionToValidate() {
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);
PromotionEntity promotionEntity1 = getAPromotionEntity("promotion#1");
PromotionEntity promotionEntity2 = getAPromotionEntity("promotion#2");
when(promotionService.search(any(), any(), any())).thenReturn(new Page<>(List.of(promotionEntity1, promotionEntity2), 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));
ArgumentCaptor<PromotionEntity> captor = ArgumentCaptor.forClass(PromotionEntity.class);
verify(promotionService, times(2)).createOrUpdate(captor.capture());
assertThat(captor.getAllValues()).extracting(PromotionEntity::getId, PromotionEntity::getStatus).containsExactlyInAnyOrder(tuple(promotionEntity1.getId(), PromotionEntityStatus.REJECTED), tuple(promotionEntity2.getId(), PromotionEntityStatus.REJECTED));
}
Aggregations