Search in sources :

Example 6 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testUserModeWithNoPO.

// USER + import with no PO
@Test
public void testUserModeWithNoPO() {
    setPrimaryOwnerMode("USER");
    defineUser(CURRENT_USER);
    JsonNode definition = noPODefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(CURRENT_USER, primaryOwner.getId());
    assertEquals("USER", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 7 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testUserModeWithExistingPOUser.

// USER + import with PO User
@Test
public void testUserModeWithExistingPOUser() {
    setPrimaryOwnerMode("USER");
    defineUser(PO_USER_ID);
    JsonNode definition = poUserDefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(PO_USER_ID, primaryOwner.getId());
    assertEquals("USER", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 8 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method testGroupModeWithNoPOAndCurrentUserBelongsToAPoGroup.

// GROUP + import with no PO
@Test
public void testGroupModeWithNoPOAndCurrentUserBelongsToAPoGroup() {
    setPrimaryOwnerMode("GROUP");
    addUserInPOGroup(CURRENT_USER, CURRENT_USER_PO_GROUP);
    JsonNode definition = noPODefinition();
    final PrimaryOwnerEntity primaryOwner = apiService.findPrimaryOwner(definition, CURRENT_USER);
    assertEquals(CURRENT_USER_PO_GROUP, primaryOwner.getId());
    assertEquals("GROUP", primaryOwner.getType());
}
Also used : PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 9 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiDocumentTransformerTest method getApiEntity.

@NotNull
private ApiEntity getApiEntity() {
    ApiEntity toTransform = new ApiEntity();
    toTransform.setId("apiId");
    toTransform.setName("name");
    toTransform.setDescription("description");
    toTransform.setReferenceId("xxxxxx");
    toTransform.setReferenceType("env1");
    UserEntity userEntity = new UserEntity();
    userEntity.setId("userId");
    userEntity.setEmail("userMail");
    userEntity.setFirstname("userFirstname");
    userEntity.setLastname("userLastname");
    PrimaryOwnerEntity primaryOwnerEntity = new PrimaryOwnerEntity(userEntity);
    toTransform.setPrimaryOwner(primaryOwnerEntity);
    Proxy proxy = new Proxy();
    proxy.setVirtualHosts(Arrays.asList(new VirtualHost("host", "path"), new VirtualHost("host2", "path2")));
    toTransform.setProxy(proxy);
    toTransform.setLabels(Arrays.asList("label1", "label2", "label2"));
    toTransform.setCategories(new HashSet<>(Arrays.asList("cat1", "cat2")));
    toTransform.setTags(new HashSet<>(Arrays.asList("tag1", "tag2")));
    Date date = new Date();
    toTransform.setCreatedAt(date);
    toTransform.setUpdatedAt(date);
    HashMap<String, Object> metadatas = new HashMap<>();
    metadatas.put("metadata1", "value1");
    metadatas.put("metadata2", "value2");
    metadatas.put("metadata3", "value3");
    toTransform.setMetadata(metadatas);
    return toTransform;
}
Also used : Proxy(io.gravitee.definition.model.Proxy) HashMap(java.util.HashMap) PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) VirtualHost(io.gravitee.definition.model.VirtualHost) UserEntity(io.gravitee.rest.api.model.UserEntity) Date(java.util.Date) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with PrimaryOwnerEntity

use of io.gravitee.rest.api.model.PrimaryOwnerEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiSubscribersResourceTest method init.

@Before
public void init() throws IOException {
    resetAllMocks();
    ApiEntity mockApi = new ApiEntity();
    mockApi.setId(API);
    UserEntity user = new UserEntity();
    user.setId(USER_NAME);
    PrimaryOwnerEntity primaryOwner = new PrimaryOwnerEntity(user);
    mockApi.setPrimaryOwner(primaryOwner);
    Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(mockApi));
    doReturn(mockApis).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
}
Also used : java.util(java.util) ArgumentMatchers(org.mockito.ArgumentMatchers) OK_200(io.gravitee.common.http.HttpStatusCode.OK_200) SubscriptionEntity(io.gravitee.rest.api.model.SubscriptionEntity) Error(io.gravitee.rest.api.portal.rest.model.Error) Collections.singletonList(java.util.Collections.singletonList) Application(io.gravitee.rest.api.portal.rest.model.Application) GroupByQuery(io.gravitee.rest.api.model.analytics.query.GroupByQuery) ArgumentCaptor(org.mockito.ArgumentCaptor) ApplicationsResponse(io.gravitee.rest.api.portal.rest.model.ApplicationsResponse) PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) ApiQuery(io.gravitee.rest.api.model.api.ApiQuery) ApplicationListItem(io.gravitee.rest.api.model.application.ApplicationListItem) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Collections.emptySet(java.util.Collections.emptySet) NOT_FOUND_404(io.gravitee.common.http.HttpStatusCode.NOT_FOUND_404) IOException(java.io.IOException) Test(org.junit.Test) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Mockito(org.mockito.Mockito) Response(javax.ws.rs.core.Response) TopHitsAnalytics(io.gravitee.rest.api.model.analytics.TopHitsAnalytics) SubscriptionQuery(io.gravitee.rest.api.model.subscription.SubscriptionQuery) Assert(org.junit.Assert) ApplicationEntity(io.gravitee.rest.api.model.ApplicationEntity) UserEntity(io.gravitee.rest.api.model.UserEntity) PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) UserEntity(io.gravitee.rest.api.model.UserEntity) Before(org.junit.Before)

Aggregations

PrimaryOwnerEntity (io.gravitee.rest.api.model.PrimaryOwnerEntity)26 Test (org.junit.Test)23 JsonNode (com.fasterxml.jackson.databind.JsonNode)16 UserEntity (io.gravitee.rest.api.model.UserEntity)9 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)8 ApplicationEntity (io.gravitee.rest.api.model.ApplicationEntity)3 ApplicationListItem (io.gravitee.rest.api.model.application.ApplicationListItem)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Mockito (org.mockito.Mockito)3 NOT_FOUND_404 (io.gravitee.common.http.HttpStatusCode.NOT_FOUND_404)2 OK_200 (io.gravitee.common.http.HttpStatusCode.OK_200)2 Proxy (io.gravitee.definition.model.Proxy)2 VirtualHost (io.gravitee.definition.model.VirtualHost)2 RatingSummaryEntity (io.gravitee.rest.api.model.RatingSummaryEntity)2 SubscriptionEntity (io.gravitee.rest.api.model.SubscriptionEntity)2 TopHitsAnalytics (io.gravitee.rest.api.model.analytics.TopHitsAnalytics)2 GroupByQuery (io.gravitee.rest.api.model.analytics.query.GroupByQuery)2 ApiEntrypointEntity (io.gravitee.rest.api.model.api.ApiEntrypointEntity)2 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)2