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