use of io.gravitee.cockpit.api.command.hello.HelloPayload in project gravitee-management-rest-api by gravitee-io.
the class HelloCommandProducerTest method produce.
@Test
public void produce() {
final InstallationEntity installationEntity = new InstallationEntity();
installationEntity.setId(INSTALLATION_ID);
installationEntity.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
when(node.hostname()).thenReturn(HOSTNAME);
when(installationService.getOrInitialize()).thenReturn(installationEntity);
final HelloCommand command = new HelloCommand();
final HelloPayload payload = new HelloPayload();
payload.setNode(new io.gravitee.cockpit.api.command.Node());
command.setPayload(payload);
final TestObserver<HelloCommand> obs = cut.prepare(command).test();
obs.awaitTerminalEvent();
obs.assertValue(helloCommand -> {
assertEquals(CUSTOM_VALUE, helloCommand.getPayload().getAdditionalInformation().get(CUSTOM_KEY));
assertTrue(helloCommand.getPayload().getAdditionalInformation().containsKey("UI_URL"));
assertTrue(helloCommand.getPayload().getAdditionalInformation().containsKey("API_URL"));
assertEquals(HOSTNAME, helloCommand.getPayload().getNode().getHostname());
assertEquals(GraviteeContext.getDefaultOrganization(), helloCommand.getPayload().getDefaultOrganizationId());
assertEquals(GraviteeContext.getDefaultEnvironment(), helloCommand.getPayload().getDefaultEnvironmentId());
assertEquals(INSTALLATION_ID, helloCommand.getPayload().getNode().getInstallationId());
assertEquals(HOSTNAME, helloCommand.getPayload().getNode().getHostname());
return true;
});
}
Aggregations