use of io.gravitee.am.service.exception.OrganizationNotFoundException in project gravitee-access-management by gravitee-io.
the class EnvironmentServiceTest method shouldCreate_organizationNotFound.
@Test
public void shouldCreate_organizationNotFound() {
when(environmentRepository.findById(ENVIRONMENT_ID, ORGANIZATION_ID)).thenReturn(Maybe.empty());
when(organizationService.findById(ORGANIZATION_ID)).thenReturn(Single.error(new OrganizationNotFoundException(ORGANIZATION_ID)));
NewEnvironment newEnvironment = new NewEnvironment();
newEnvironment.setName("TestName");
newEnvironment.setDescription("TestDescription");
newEnvironment.setDomainRestrictions(Collections.singletonList("TestDomainRestriction"));
DefaultUser createdBy = new DefaultUser("test");
createdBy.setId(USER_ID);
TestObserver<Environment> obs = cut.createOrUpdate(ORGANIZATION_ID, ENVIRONMENT_ID, newEnvironment, createdBy).test();
obs.awaitTerminalEvent();
obs.assertError(OrganizationNotFoundException.class);
verifyZeroInteractions(auditService);
}
use of io.gravitee.am.service.exception.OrganizationNotFoundException in project gravitee-access-management by gravitee-io.
the class MembersResourceTest method shouldNotAddMember_organizationNotFound.
@Test
public void shouldNotAddMember_organizationNotFound() {
final String organizationId = "orga-1";
doReturn(Single.error(new OrganizationNotFoundException(organizationId))).when(organizationService).findById(organizationId);
NewMembership newMembership = new NewMembership();
newMembership.setMemberId("member#1");
newMembership.setMemberType(MemberType.USER);
newMembership.setRole("role#1");
final Response response = target("/organizations").path(organizationId).path("members").request().post(Entity.json(newMembership));
assertEquals(HttpStatusCode.NOT_FOUND_404, response.getStatus());
}
use of io.gravitee.am.service.exception.OrganizationNotFoundException in project gravitee-access-management by gravitee-io.
the class MembersResourceTest method shouldGetMembers_organizationNotFound.
@Test
public void shouldGetMembers_organizationNotFound() {
Organization organization = new Organization();
organization.setId("orga#1");
Membership membership = new Membership();
membership.setId("membership#1");
doReturn(Single.error(new OrganizationNotFoundException(organization.getId()))).when(organizationService).findById(organization.getId());
final Response response = target("organizations").path(organization.getId()).path("members").request().get();
assertEquals(HttpStatusCode.NOT_FOUND_404, response.getStatus());
}
use of io.gravitee.am.service.exception.OrganizationNotFoundException in project gravitee-access-management by gravitee-io.
the class MemberResourceTest method shouldNotDeleteMember_organizationNotFound.
@Test
public void shouldNotDeleteMember_organizationNotFound() {
final String organizationId = "orga-1";
doReturn(Single.error(new OrganizationNotFoundException(organizationId))).when(organizationService).findById(organizationId);
final Response response = target("/organizations").path(organizationId).path("members").path("membership-1").request().delete();
assertEquals(HttpStatusCode.NOT_FOUND_404, response.getStatus());
}
Aggregations