use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.
the class ScopeServiceTest method shouldUpdate_nonSystemScope_discoveryReplaced.
@Test
public void shouldUpdate_nonSystemScope_discoveryReplaced() {
UpdateScope updateScope = new UpdateScope();
updateScope.setDiscovery(true);
updateScope.setName("name");
final String scopeId = "toUpdateId";
Scope toUpdate = new Scope();
toUpdate.setId(scopeId);
toUpdate.setSystem(false);
toUpdate.setDiscovery(false);
toUpdate.setName("oldName");
toUpdate.setDescription("oldDescription");
ArgumentCaptor<Scope> argument = ArgumentCaptor.forClass(Scope.class);
when(scopeRepository.findById(scopeId)).thenReturn(Maybe.just(toUpdate));
when(scopeRepository.update(argument.capture())).thenReturn(Single.just(new Scope()));
when(eventService.create(any())).thenReturn(Single.just(new Event()));
TestObserver testObserver = scopeService.update(DOMAIN, scopeId, updateScope).test();
testObserver.assertComplete();
testObserver.assertNoErrors();
verify(scopeRepository, times(1)).update(any(Scope.class));
assertNotNull(argument.getValue());
assertEquals("name", argument.getValue().getName());
assertNull(argument.getValue().getDescription());
assertTrue(argument.getValue().isDiscovery());
}
use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.
the class ScopeServiceTest method shouldNotDeleteSystemScope.
@Test
public void shouldNotDeleteSystemScope() throws TechnicalException {
Scope scope = new Scope();
scope.setKey("scope-key");
scope.setSystem(true);
when(scopeRepository.findById("scope-id")).thenReturn(Maybe.just(scope));
TestObserver testObserver = scopeService.delete("scope-id", false).test();
testObserver.assertError(SystemScopeDeleteException.class);
testObserver.assertNotComplete();
}
use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.
the class ScopeServiceTest method shouldNotCreate_malformedIconUri.
@Test
public void shouldNotCreate_malformedIconUri() {
NewScope newScope = Mockito.mock(NewScope.class);
when(newScope.getKey()).thenReturn("my-scope");
when(newScope.getIconUri()).thenReturn("malformedIconUri");
when(scopeRepository.findByDomainAndKey(DOMAIN, "my-scope")).thenReturn(Maybe.empty());
TestObserver testObserver = new TestObserver();
scopeService.create(DOMAIN, newScope).subscribe(testObserver);
testObserver.assertError(MalformedIconUriException.class);
testObserver.assertNotComplete();
verify(scopeRepository, times(1)).findByDomainAndKey(DOMAIN, "my-scope");
verify(scopeRepository, never()).create(any(Scope.class));
}
use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.
the class ScopeServiceTest method shouldPatch_systemScope_discoveryNotReplaced.
@Test
public void shouldPatch_systemScope_discoveryNotReplaced() {
PatchScope patch = new PatchScope();
patch.setDiscovery(Optional.of(true));
patch.setName(Optional.of("name"));
final String scopeId = "toPatchId";
Scope toPatch = new Scope();
toPatch.setId(scopeId);
toPatch.setSystem(true);
toPatch.setDiscovery(false);
toPatch.setName("oldName");
toPatch.setDescription("oldDescription");
ArgumentCaptor<Scope> argument = ArgumentCaptor.forClass(Scope.class);
when(scopeRepository.findById(scopeId)).thenReturn(Maybe.just(toPatch));
when(scopeRepository.update(argument.capture())).thenReturn(Single.just(new Scope()));
when(eventService.create(any())).thenReturn(Single.just(new Event()));
TestObserver testObserver = scopeService.patch(DOMAIN, scopeId, patch).test();
testObserver.assertComplete();
testObserver.assertNoErrors();
verify(scopeRepository, times(1)).update(any(Scope.class));
assertNotNull(argument.getValue());
assertEquals("name", argument.getValue().getName());
assertEquals("oldDescription", argument.getValue().getDescription());
assertFalse(argument.getValue().isDiscovery());
}
use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project gravitee-access-management by gravitee-io.
the class ScopeServiceTest method shouldUpdateSystemScope.
@Test
public void shouldUpdateSystemScope() {
UpdateSystemScope updateScope = new UpdateSystemScope();
updateScope.setDiscovery(true);
updateScope.setName("name");
final String scopeId = "toUpdateId";
Scope toUpdate = new Scope();
toUpdate.setId(scopeId);
toUpdate.setSystem(true);
toUpdate.setDiscovery(false);
toUpdate.setName("oldName");
toUpdate.setDescription("oldDescription");
ArgumentCaptor<Scope> argument = ArgumentCaptor.forClass(Scope.class);
when(scopeRepository.findById(scopeId)).thenReturn(Maybe.just(toUpdate));
when(scopeRepository.update(argument.capture())).thenReturn(Single.just(new Scope()));
when(eventService.create(any())).thenReturn(Single.just(new Event()));
TestObserver testObserver = scopeService.update(DOMAIN, scopeId, updateScope).test();
testObserver.assertComplete();
testObserver.assertNoErrors();
verify(scopeRepository, times(1)).update(any(Scope.class));
assertNotNull(argument.getValue());
assertEquals("name", argument.getValue().getName());
assertNull(argument.getValue().getDescription());
assertTrue(argument.getValue().isDiscovery());
}
Aggregations