Search in sources :

Example 41 with Resource

use of io.gravitee.am.model.uma.Resource in project gravitee-access-management by gravitee-io.

the class ResourceServiceTest method getMetadata_resources.

@Test
public void getMetadata_resources() {
    Resource resource = new Resource();
    resource.setDomain(DOMAIN_ID);
    resource.setClientId(CLIENT_ID);
    resource.setUserId(USER_ID);
    List<Resource> resources = Collections.singletonList(resource);
    when(userService.findByIdIn(anyList())).thenReturn(Flowable.just(new User()));
    when(applicationService.findByIdIn(anyList())).thenReturn(Flowable.just(new Application()));
    TestObserver<Map<String, Map<String, Object>>> testObserver = service.getMetadata(resources).test();
    testObserver.assertComplete().assertNoErrors();
}
Also used : User(io.gravitee.am.model.User) Resource(io.gravitee.am.model.uma.Resource) NewResource(io.gravitee.am.service.model.NewResource) JsonObject(io.vertx.core.json.JsonObject) Application(io.gravitee.am.model.Application) Test(org.junit.Test)

Example 42 with Resource

use of io.gravitee.am.model.uma.Resource in project gravitee-access-management by gravitee-io.

the class ResourceServiceTest method delete.

@Test
public void delete() {
    Resource toDelete = new Resource().setId(RESOURCE_ID).setDomain(DOMAIN_ID);
    when(accessPolicyRepository.findByDomainAndResource(toDelete.getDomain(), toDelete.getId())).thenReturn(Flowable.empty());
    when(repository.delete(RESOURCE_ID)).thenReturn(Completable.complete());
    TestObserver testObserver = service.delete(toDelete).test();
    testObserver.assertComplete().assertNoErrors();
    verify(repository, times(1)).delete(RESOURCE_ID);
}
Also used : Resource(io.gravitee.am.model.uma.Resource) NewResource(io.gravitee.am.service.model.NewResource) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Aggregations

Resource (io.gravitee.am.model.uma.Resource)42 Test (org.junit.Test)30 NewResource (io.gravitee.am.service.model.NewResource)14 JsonObject (io.vertx.core.json.JsonObject)12 PermissionRequest (io.gravitee.am.model.uma.PermissionRequest)10 PermissionTicket (io.gravitee.am.model.uma.PermissionTicket)10 AbstractManagementTest (io.gravitee.am.repository.management.AbstractManagementTest)9 Single (io.reactivex.Single)6 Page (io.gravitee.am.model.common.Page)5 ResourceService (io.gravitee.am.service.ResourceService)5 InvalidPermissionRequestException (io.gravitee.am.service.exception.InvalidPermissionRequestException)5 JWT (io.gravitee.am.common.jwt.JWT)4 Maybe (io.reactivex.Maybe)4 InvalidRequestException (io.gravitee.am.common.exception.oauth2.InvalidRequestException)3 Client (io.gravitee.am.model.oidc.Client)3 List (java.util.List)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 ConstantKeys (io.gravitee.am.common.utils.ConstantKeys)2 RandomString (io.gravitee.am.common.utils.RandomString)2 UriBuilderRequest (io.gravitee.am.gateway.handler.common.vertx.utils.UriBuilderRequest)2