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());
}
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);
}
Aggregations