Search in sources :

Example 6 with NewResource

use of io.gravitee.am.service.model.NewResource in project gravitee-access-management by gravitee-io.

the class ResourceServiceTest method update_scopeNotFound.

@Test
public void update_scopeNotFound() {
    NewResource newResource = new JsonObject("{\"resource_scopes\":[\"scope\"]}").mapTo(NewResource.class);
    Resource exitingRS = new Resource().setId(RESOURCE_ID).setDomain(DOMAIN_ID);
    when(scopeService.findByDomainAndKeys(DOMAIN_ID, Arrays.asList("scope"))).thenReturn(Single.just(Collections.emptyList()));
    when(repository.findByDomainAndClientAndUserAndResource(DOMAIN_ID, CLIENT_ID, USER_ID, RESOURCE_ID)).thenReturn(Maybe.just(exitingRS));
    TestObserver<Resource> testObserver = service.update(newResource, DOMAIN_ID, CLIENT_ID, USER_ID, RESOURCE_ID).test();
    testObserver.assertError(ScopeNotFoundException.class);
    verify(repository, times(0)).update(any());
}
Also used : NewResource(io.gravitee.am.service.model.NewResource) Resource(io.gravitee.am.model.uma.Resource) NewResource(io.gravitee.am.service.model.NewResource) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 7 with NewResource

use of io.gravitee.am.service.model.NewResource in project gravitee-access-management by gravitee-io.

the class ResourceServiceTest method update_nonExistingResource.

@Test
public void update_nonExistingResource() {
    when(repository.findByDomainAndClientAndUserAndResource(DOMAIN_ID, CLIENT_ID, USER_ID, RESOURCE_ID)).thenReturn(Maybe.empty());
    TestObserver testObserver = service.update(new NewResource(), DOMAIN_ID, CLIENT_ID, USER_ID, RESOURCE_ID).test();
    testObserver.assertError(ResourceNotFoundException.class);
}
Also used : NewResource(io.gravitee.am.service.model.NewResource) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test)

Aggregations

NewResource (io.gravitee.am.service.model.NewResource)7 Resource (io.gravitee.am.model.uma.Resource)6 Test (org.junit.Test)6 JsonObject (io.vertx.core.json.JsonObject)5 AccessPolicy (io.gravitee.am.model.uma.policy.AccessPolicy)2 TestObserver (io.reactivex.observers.TestObserver)1