use of io.gravitee.cockpit.api.command.installation.InstallationCommand in project gravitee-management-rest-api by gravitee-io.
the class InstallationCommandHandlerTest method handle.
@Test
public void handle() {
final InstallationEntity installation = new InstallationEntity();
installation.setId(INSTALLATION_ID);
installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
InstallationPayload installationPayload = new InstallationPayload();
InstallationCommand command = new InstallationCommand(installationPayload);
installationPayload.setId(INSTALLATION_ID);
installationPayload.setStatus("ACCEPTED");
when(installationService.getOrInitialize()).thenReturn(installation);
TestObserver<InstallationReply> 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, "ACCEPTED");
verify(installationService, times(1)).setAdditionalInformation(expectedAdditionalInfos);
}
use of io.gravitee.cockpit.api.command.installation.InstallationCommand in project gravitee-management-rest-api by gravitee-io.
the class InstallationCommandHandlerTest method handleWithException.
@Test
public void handleWithException() {
final InstallationEntity installation = new InstallationEntity();
installation.setId(INSTALLATION_ID);
installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
InstallationPayload installationPayload = new InstallationPayload();
InstallationCommand command = new InstallationCommand(installationPayload);
installationPayload.setId(INSTALLATION_ID);
installationPayload.setStatus("ACCEPTED");
when(installationService.getOrInitialize()).thenReturn(installation);
when(installationService.setAdditionalInformation(anyMap())).thenThrow(new TechnicalManagementException());
TestObserver<InstallationReply> obs = cut.handle(command).test();
obs.awaitTerminalEvent();
obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.ERROR));
}
Aggregations