use of io.gravitee.am.model.Environment in project gravitee-access-management by gravitee-io.
the class EnvironmentRepositoryTest method testUpdate.
@Test
public void testUpdate() {
Environment env = buildEnv();
Environment envCreated = environmentRepository.create(env).blockingGet();
Environment envUpdated = new Environment();
envUpdated.setId(envCreated.getId());
envUpdated.setOrganizationId(env.getOrganizationId());
envUpdated.setName("testNameUpdated");
envUpdated.setDomainRestrictions(Arrays.asList("ValueDom2", "ValueDom3", "ValueDom4"));
envUpdated.setHrids(Arrays.asList("Hrid2", "Hrid3", "Hrid4"));
TestObserver<Environment> obs = environmentRepository.update(envUpdated).test();
obs.awaitTerminalEvent();
obs.assertComplete();
obs.assertNoErrors();
obs.assertValue(e -> e.getName().equals(envUpdated.getName()) && e.getId().equals(envCreated.getId()));
obs.assertValue(e -> e.getDomainRestrictions().containsAll(envUpdated.getDomainRestrictions()));
obs.assertValue(e -> e.getHrids().containsAll(envUpdated.getHrids()));
}
use of io.gravitee.am.model.Environment in project gravitee-access-management by gravitee-io.
the class EnvironmentRepositoryTest method testDelete.
@Test
public void testDelete() {
Environment env = new Environment();
env.setName("testName");
env.setOrganizationId(UUID.randomUUID().toString());
env.setDescription("testDescription");
env.setCreatedAt(new Date());
env.setUpdatedAt(env.getUpdatedAt());
env.setDomainRestrictions(Arrays.asList("ValueDom1", "ValueDom2"));
env.setHrids(Arrays.asList("Hrid1", "Hrid2"));
Environment envCreated = environmentRepository.create(env).blockingGet();
assertNotNull(environmentRepository.findById(envCreated.getId()).blockingGet());
TestObserver<Void> obs = environmentRepository.delete(envCreated.getId()).test();
obs.awaitTerminalEvent();
obs.assertNoValues();
assertNull(environmentRepository.findById(envCreated.getId()).blockingGet());
}
use of io.gravitee.am.model.Environment in project gravitee-access-management by gravitee-io.
the class EnvironmentRepositoryTest method testCreate.
@Test
public void testCreate() {
Environment env = buildEnv();
env.setOrganizationId(UUID.randomUUID().toString());
env.setName("testName");
TestObserver<Environment> obs = environmentRepository.create(env).test();
obs.awaitTerminalEvent();
obs.assertComplete();
obs.assertNoErrors();
obs.assertValue(e -> e.getName().equals(env.getName()) && e.getId() != null);
obs.assertValue(e -> e.getOrganizationId().equals(env.getOrganizationId()) && e.getId() != null);
obs.assertValue(e -> e.getName().equals(env.getName()));
obs.assertValue(e -> e.getDescription().equals(env.getDescription()));
obs.assertValue(e -> e.getOrganizationId().equals(env.getOrganizationId()));
obs.assertValue(e -> e.getDomainRestrictions().containsAll(env.getDomainRestrictions()));
obs.assertValue(e -> e.getHrids().containsAll(env.getHrids()));
}
use of io.gravitee.am.model.Environment in project gravitee-access-management by gravitee-io.
the class DomainNotificationServiceTest method prepareTest.
@Before
public void prepareTest() {
ReflectionTestUtils.setField(cut, "emailNotifierEnabled", true);
env = new Environment();
env.setId(ENV_ID);
env.setOrganizationId(ORGANIZATION_ID);
domain = new Domain();
domain.setId(DOMAIN_ID);
domain.setReferenceId(ENV_ID);
domain.setReferenceType(ReferenceType.ENVIRONMENT);
certificate = new Certificate();
certificate.setDomain(domain.getId());
when(domainService.findById(certificate.getDomain())).thenReturn(Maybe.just(domain));
when(environmentService.findById(domain.getReferenceId())).thenReturn(Single.just(env));
final Role role = new Role();
role.setId("role#1");
when(roleService.findSystemRole(SystemRole.DOMAIN_PRIMARY_OWNER, ReferenceType.DOMAIN)).thenReturn(Maybe.just(role));
final Role role2 = new Role();
role2.setId("role#2");
when(roleService.findDefaultRole(ORGANIZATION_ID, DefaultRole.DOMAIN_OWNER, ReferenceType.DOMAIN)).thenReturn(Maybe.just(role2));
}
use of io.gravitee.am.model.Environment in project gravitee-access-management by gravitee-io.
the class EnvironmentServiceTest method shouldFindByIdAndOrgId.
@Test
public void shouldFindByIdAndOrgId() {
Environment environment = new Environment();
when(environmentRepository.findById(ENVIRONMENT_ID, ORGANIZATION_ID)).thenReturn(Maybe.just(environment));
TestObserver<Environment> obs = cut.findById(ENVIRONMENT_ID, ORGANIZATION_ID).test();
obs.awaitTerminalEvent();
obs.assertComplete();
obs.assertValue(environment);
}
Aggregations