Search in sources :

Example 1 with OrganizationNotFoundException

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);
}
Also used : NewEnvironment(io.gravitee.am.service.model.NewEnvironment) OrganizationNotFoundException(io.gravitee.am.service.exception.OrganizationNotFoundException) DefaultUser(io.gravitee.am.identityprovider.api.DefaultUser) Environment(io.gravitee.am.model.Environment) NewEnvironment(io.gravitee.am.service.model.NewEnvironment) Test(org.junit.Test)

Example 2 with OrganizationNotFoundException

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());
}
Also used : Response(javax.ws.rs.core.Response) OrganizationNotFoundException(io.gravitee.am.service.exception.OrganizationNotFoundException) NewMembership(io.gravitee.am.service.model.NewMembership) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 3 with OrganizationNotFoundException

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());
}
Also used : Response(javax.ws.rs.core.Response) OrganizationNotFoundException(io.gravitee.am.service.exception.OrganizationNotFoundException) Organization(io.gravitee.am.model.Organization) Membership(io.gravitee.am.model.Membership) NewMembership(io.gravitee.am.service.model.NewMembership) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 4 with OrganizationNotFoundException

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());
}
Also used : Response(javax.ws.rs.core.Response) OrganizationNotFoundException(io.gravitee.am.service.exception.OrganizationNotFoundException) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest) Test(org.junit.Test)

Aggregations

OrganizationNotFoundException (io.gravitee.am.service.exception.OrganizationNotFoundException)4 Test (org.junit.Test)4 JerseySpringTest (io.gravitee.am.management.handlers.management.api.JerseySpringTest)3 Response (javax.ws.rs.core.Response)3 NewMembership (io.gravitee.am.service.model.NewMembership)2 DefaultUser (io.gravitee.am.identityprovider.api.DefaultUser)1 Environment (io.gravitee.am.model.Environment)1 Membership (io.gravitee.am.model.Membership)1 Organization (io.gravitee.am.model.Organization)1 NewEnvironment (io.gravitee.am.service.model.NewEnvironment)1