use of org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope in project bgpcep by opendaylight.
the class ConnectedGraphServer method createConnectedGraph.
@Override
public ConnectedGraph createConnectedGraph(final String name, final DomainScope scope) {
Graph graph = new GraphBuilder().setName(name).setDomainScope(scope).build();
addToDataStore(getGraphInstanceIdentifier(name), graph, "Graph(" + name + ")");
ConnectedGraphImpl cgraph = new ConnectedGraphImpl(graph, this);
graphs.put(graph.key(), cgraph);
return cgraph;
}
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 ScopeResourceTest method shouldGetScope_wrongDomain.
@Test
public void shouldGetScope_wrongDomain() {
final String domainId = "domain-id";
final Domain mockDomain = new Domain();
mockDomain.setId(domainId);
final String scopeId = "scope-id";
final Scope mockScope = new Scope();
mockScope.setId(scopeId);
mockScope.setKey(scopeId);
mockScope.setName("scope-name");
mockScope.setDomain("wrong-domain");
doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
doReturn(Maybe.just(mockScope)).when(scopeService).findById(scopeId);
final Response response = target("domains").path(domainId).path("scopes").path(scopeId).request().get();
assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
}
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 ScopesResourceTest method shouldCreate.
@Test
public void shouldCreate() {
final String domainId = "domain-1";
final Domain mockDomain = new Domain();
mockDomain.setId(domainId);
NewScope newScope = new NewScope();
newScope.setKey("scope-key");
newScope.setName("scope-name");
newScope.setDescription("scope-description");
Scope scope = new Scope();
scope.setId("scope-id");
scope.setKey("scope-key");
scope.setName("scope-name");
doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
doReturn(Single.just(scope)).when(scopeService).create(eq(domainId), any(NewScope.class), any());
final Response response = target("domains").path(domainId).path("scopes").request().post(Entity.json(newScope));
assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
}
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 ScopesResourceTest method shouldGetScopes.
@Test
public void shouldGetScopes() {
final String domainId = "domain-1";
final Scope mockScope = new Scope();
mockScope.setId("scope-1-id");
mockScope.setKey("scope-1-id");
mockScope.setName("scope-1-name");
mockScope.setDomain(domainId);
final Scope mockScope2 = new Scope();
mockScope2.setId("scope-2-id");
mockScope2.setKey("scope-2-id");
mockScope2.setName("scope-2-name");
mockScope2.setDomain(domainId);
final Set<Scope> scopes = new HashSet<>(Arrays.asList(mockScope, mockScope2));
doReturn(Single.just(new Page<>(scopes, 0, 2))).when(scopeService).findByDomain(domainId, 0, 50);
final Response response = target("domains").path(domainId).path("scopes").request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
String body = response.readEntity(String.class);
JsonArray data = new JsonObject(body).getJsonArray("data");
assertTrue(data.size() == 2);
}
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 UserConsentsResourceTest method shouldGetUserConsents.
@Test
public void shouldGetUserConsents() {
final String domainId = "domain-1";
final Domain mockDomain = new Domain();
mockDomain.setId(domainId);
final User mockUser = new User();
mockUser.setId("user-id-1");
final Application mockClient = new Application();
mockClient.setId("client-id-1");
final Scope mockScope = new Scope();
mockScope.setId("scope-id-1");
mockScope.setKey("scope");
final ScopeApproval scopeApproval = new ScopeApproval();
scopeApproval.setUserId("user-id-1");
scopeApproval.setClientId("clientId");
scopeApproval.setScope("scope");
scopeApproval.setDomain(domainId);
doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
doReturn(Maybe.just(mockClient)).when(applicationService).findByDomainAndClientId(domainId, scopeApproval.getClientId());
doReturn(Maybe.just(mockScope)).when(scopeService).findByDomainAndKey(domainId, scopeApproval.getScope());
doReturn(Flowable.just(scopeApproval)).when(scopeApprovalService).findByDomainAndUser(domainId, mockUser.getId());
final Response response = target("domains").path(domainId).path("users").path(mockUser.getId()).path("consents").request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
}
Aggregations