use of io.gravitee.rest.api.model.UserEntity in project gravitee-management-rest-api by gravitee-io.
the class MetadataServiceTest method checkMetadataFormat_nominalCase_EL.
@Test
public void checkMetadataFormat_nominalCase_EL() {
UserEntity userEntity = new UserEntity();
userEntity.setEmail("gs@support.com");
PrimaryOwnerEntity primaryOwnerEntity = new PrimaryOwnerEntity(userEntity);
ApiEntity apiEntity = new ApiEntity();
apiEntity.setPrimaryOwner(primaryOwnerEntity);
metadataService.checkMetadataFormat(MetadataFormat.MAIL, "${api.primaryOwner.email}", API, apiEntity);
}
use of io.gravitee.rest.api.model.UserEntity in project gravitee-management-rest-api by gravitee-io.
the class MembershipService_GetMembersTest method shouldGetMembersWithMembership.
@Test
public void shouldGetMembersWithMembership() throws Exception {
Membership membership = new Membership();
membership.setReferenceId(API_ID);
membership.setCreatedAt(new Date());
membership.setUpdatedAt(membership.getCreatedAt());
membership.setReferenceType(MembershipReferenceType.API);
membership.setRoleId("API_PRIMARY_OWNER");
membership.setMemberId("user-id");
membership.setMemberType(MembershipMemberType.USER);
UserEntity userEntity = new UserEntity();
userEntity.setId(membership.getMemberId());
userEntity.setFirstname("John");
userEntity.setLastname("Doe");
RoleEntity po = mock(RoleEntity.class);
po.setName(SystemRole.PRIMARY_OWNER.name());
List<String> memberIds = Collections.singletonList(membership.getMemberId());
Set<UserEntity> userEntities = Collections.singleton(userEntity);
when(membershipRepository.findByReferencesAndRoleId(MembershipReferenceType.API, Collections.singletonList(API_ID), "API_PRIMARY_OWNER")).thenReturn(Collections.singleton(membership));
when(userService.findByIds(memberIds, false)).thenReturn(userEntities);
when(roleService.findById("API_PRIMARY_OWNER")).thenReturn(po);
Set<MemberEntity> members = membershipService.getMembersByReferenceAndRole(io.gravitee.rest.api.model.MembershipReferenceType.API, API_ID, "API_PRIMARY_OWNER");
Assert.assertNotNull(members);
Assert.assertFalse("members must not be empty", members.isEmpty());
verify(membershipRepository, times(1)).findByReferencesAndRoleId(MembershipReferenceType.API, Collections.singletonList(API_ID), "API_PRIMARY_OWNER");
verify(userService, times(1)).findByIds(memberIds, false);
}
Aggregations