use of org.collectiveone.modules.users.AppUserDto in project CollectiveOneWebapp by CollectiveOne.
the class TestElementOrder method setUp.
@SuppressWarnings("serial")
@Before
public void setUp() throws Exception {
AuthAPI auth = new AuthAPI(auth0Domain, clientId, clientSecret);
AuthRequest request = auth.login(testEmail1, testPwd1).setScope("openid contacts");
try {
TokenHolder holder = request.execute();
authorizationTokenUser1 = holder.getIdToken();
} catch (APIException exception) {
System.out.println(exception);
} catch (Auth0Exception exception) {
System.out.println(exception);
}
MvcResult result = this.mockMvc.perform(get("/1/user/myProfile").header("Authorization", "Bearer " + authorizationTokenUser1)).andReturn();
assertEquals("error in http request: " + result.getResponse().getErrorMessage(), 200, result.getResponse().getStatus());
GetResult<AppUserDto> getResultUser = gson.fromJson(result.getResponse().getContentAsString(), new TypeToken<GetResult<AppUserDto>>() {
}.getType());
user1 = getResultUser.getData();
logger.debug("Test user created:" + result.getResponse().getContentAsString());
request = auth.login(testEmail2, testPwd2).setScope("openid contacts");
try {
TokenHolder holder = request.execute();
authorizationTokenUser2 = holder.getIdToken();
} catch (APIException exception) {
System.out.println(exception);
} catch (Auth0Exception exception) {
System.out.println(exception);
}
result = this.mockMvc.perform(get("/1/user/myProfile").header("Authorization", "Bearer " + authorizationTokenUser2)).andReturn();
assertEquals("error in http request: " + result.getResponse().getErrorMessage(), 200, result.getResponse().getStatus());
getResultUser = gson.fromJson(result.getResponse().getContentAsString(), new TypeToken<GetResult<AppUserDto>>() {
}.getType());
user2 = getResultUser.getData();
logger.debug("Test user created: " + result.getResponse().getContentAsString());
/**
* create initiative
*/
NewInitiativeDto initiativeDto = new NewInitiativeDto(initiativeName, "");
MemberDto member = new MemberDto();
member.setRole("ADMIN");
member.setUser(user1);
initiativeDto.getMembers().add(member);
result = this.mockMvc.perform(post("/1/initiative/create").header("Authorization", "Bearer " + authorizationTokenUser1).contentType(MediaType.APPLICATION_JSON).content(gson.toJson(initiativeDto))).andReturn();
assertEquals("error in http request: " + result.getResponse().getErrorMessage(), 200, result.getResponse().getStatus());
PostResult postResult = gson.fromJson(result.getResponse().getContentAsString(), PostResult.class);
initiativeId = postResult.getElementId();
logger.debug("Initiative created: " + initiativeId);
result = this.mockMvc.perform(get("/1/initiative/" + initiativeId).header("Authorization", "Bearer " + authorizationTokenUser1)).andReturn();
GetResult<InitiativeDto> getResultInit = gson.fromJson(result.getResponse().getContentAsString(), new TypeToken<GetResult<InitiativeDto>>() {
}.getType());
initiative = getResultInit.getData();
logger.debug("Initiative retrieved: " + result.getResponse().getContentAsString());
}
use of org.collectiveone.modules.users.AppUserDto in project CollectiveOneWebapp by CollectiveOne.
the class InitiativeService method getMembersOfEcosystem.
@Transactional
public GetResult<List<AppUserDto>> getMembersOfEcosystem(UUID initiativeId, String query, PageRequest page) {
List<UUID> ecosystemIds = findAllInitiativeEcosystemIds(initiativeId);
Page<AppUser> allMemberUsers = memberRepository.findMembersOfInitiatives(ecosystemIds, query.toLowerCase(), page);
List<AppUserDto> allMembersDto = new ArrayList<AppUserDto>();
for (AppUser user : allMemberUsers.getContent()) {
allMembersDto.add(user.toDtoLight());
}
return new GetResult<List<AppUserDto>>("success", "members retrieved", allMembersDto);
}
Aggregations