Search in sources :

Example 1 with HelloReply

use of io.gravitee.cockpit.api.command.hello.HelloReply in project gravitee-management-rest-api by gravitee-io.

the class HelloCommandProducerTest method handleReplay_shouldUpdateDefaultOrganizationCockpitId.

@Test
public void handleReplay_shouldUpdateDefaultOrganizationCockpitId() {
    HelloReply helloReply = new HelloReply();
    helloReply.setCommandStatus(CommandStatus.SUCCEEDED);
    helloReply.setDefaultOrganizationCockpitId("org#cockpit-1");
    String defaultOrgId = "DEFAULT";
    OrganizationEntity defaultOrganization = new OrganizationEntity();
    defaultOrganization.setId(defaultOrgId);
    when(organizationService.findById(defaultOrgId)).thenReturn(defaultOrganization);
    cut.handleReply(helloReply);
    verify(organizationService).createOrUpdate(eq(defaultOrgId), argThat(org -> org.getCockpitId().equals("org#cockpit-1")));
}
Also used : ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) GraviteeContext(io.gravitee.rest.api.service.common.GraviteeContext) Command(io.gravitee.cockpit.api.command.Command) InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) Before(org.junit.Before) Node(io.gravitee.node.api.Node) OrganizationEntity(io.gravitee.rest.api.model.OrganizationEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) InstallationService(io.gravitee.rest.api.service.InstallationService) Assert.assertTrue(org.junit.Assert.assertTrue) EnvironmentService(io.gravitee.rest.api.service.EnvironmentService) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) OrganizationService(io.gravitee.rest.api.service.OrganizationService) EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) Mockito.verify(org.mockito.Mockito.verify) HelloPayload(io.gravitee.cockpit.api.command.hello.HelloPayload) CommandStatus(io.gravitee.cockpit.api.command.CommandStatus) HelloCommand(io.gravitee.cockpit.api.command.hello.HelloCommand) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) OrganizationEntity(io.gravitee.rest.api.model.OrganizationEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) Test(org.junit.Test)

Example 2 with HelloReply

use of io.gravitee.cockpit.api.command.hello.HelloReply in project gravitee-management-rest-api by gravitee-io.

the class HelloCommandProducerTest method handleReplay_shouldUpdateDefaultEnvironmentCockpitId.

@Test
public void handleReplay_shouldUpdateDefaultEnvironmentCockpitId() {
    HelloReply helloReply = new HelloReply();
    helloReply.setCommandStatus(CommandStatus.SUCCEEDED);
    helloReply.setDefaultEnvironmentCockpitId("env#cockpit-1");
    String defaultEnvId = "DEFAULT";
    EnvironmentEntity defaultEnvironment = new EnvironmentEntity();
    defaultEnvironment.setId(defaultEnvId);
    defaultEnvironment.setOrganizationId("org#1");
    when(environmentService.findById(defaultEnvId)).thenReturn(defaultEnvironment);
    cut.handleReply(helloReply);
    verify(environmentService).createOrUpdate(eq(defaultEnvironment.getOrganizationId()), eq(defaultEnvId), argThat(env -> env.getCockpitId().equals("env#cockpit-1")));
}
Also used : ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) GraviteeContext(io.gravitee.rest.api.service.common.GraviteeContext) Command(io.gravitee.cockpit.api.command.Command) InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) Before(org.junit.Before) Node(io.gravitee.node.api.Node) OrganizationEntity(io.gravitee.rest.api.model.OrganizationEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) InstallationService(io.gravitee.rest.api.service.InstallationService) Assert.assertTrue(org.junit.Assert.assertTrue) EnvironmentService(io.gravitee.rest.api.service.EnvironmentService) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) OrganizationService(io.gravitee.rest.api.service.OrganizationService) EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) Mockito.verify(org.mockito.Mockito.verify) HelloPayload(io.gravitee.cockpit.api.command.hello.HelloPayload) CommandStatus(io.gravitee.cockpit.api.command.CommandStatus) HelloCommand(io.gravitee.cockpit.api.command.hello.HelloCommand) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) Test(org.junit.Test)

Aggregations

Command (io.gravitee.cockpit.api.command.Command)2 CommandStatus (io.gravitee.cockpit.api.command.CommandStatus)2 HelloCommand (io.gravitee.cockpit.api.command.hello.HelloCommand)2 HelloPayload (io.gravitee.cockpit.api.command.hello.HelloPayload)2 HelloReply (io.gravitee.cockpit.api.command.hello.HelloReply)2 Node (io.gravitee.node.api.Node)2 EnvironmentEntity (io.gravitee.rest.api.model.EnvironmentEntity)2 InstallationEntity (io.gravitee.rest.api.model.InstallationEntity)2 OrganizationEntity (io.gravitee.rest.api.model.OrganizationEntity)2 EnvironmentService (io.gravitee.rest.api.service.EnvironmentService)2 InstallationService (io.gravitee.rest.api.service.InstallationService)2 OrganizationService (io.gravitee.rest.api.service.OrganizationService)2 GraviteeContext (io.gravitee.rest.api.service.common.GraviteeContext)2 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)2 TestObserver (io.reactivex.observers.TestObserver)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2