use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.
the class RegisterUserServiceITest method serviceRegisterUserRequestWeakPasswordFailureTest.
/**
* Service register user request weak password failure test.
*
* @throws Exception
* the exception
*/
@Test
public void serviceRegisterUserRequestWeakPasswordFailureTest() throws Exception {
final CreateApplicationSessionRequest createApplicationSesstion = createApplicationSesstionWithRoleAnonymous();
final RegisterUserRequest serviceRequest = new RegisterUserRequest();
serviceRequest.setCountry("Sweden");
serviceRequest.setUsername(UUID.randomUUID().toString());
serviceRequest.setEmail(serviceRequest.getUsername() + "@email.com");
serviceRequest.setUserpassword("weak");
serviceRequest.setUserType(UserType.PRIVATE);
serviceRequest.setSessionId(createApplicationSesstion.getSessionId());
final RegisterUserResponse errorResponse = (RegisterUserResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, errorResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.FAILURE, errorResponse.getResult());
assertEquals("[Password must be 8 or more characters in length., Password must contain 1 or more uppercase characters., Password must contain 1 or more digit characters., Password must contain 1 or more special characters.]", errorResponse.getErrorMessage());
final DataContainer<UserAccount, Long> dataContainer = applicationManager.getDataContainer(UserAccount.class);
final List<UserAccount> allBy = dataContainer.getAllBy(UserAccount_.username, serviceRequest.getUsername());
assertEquals(0, allBy.size());
}
use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.
the class RegisterUserServiceITest method serviceRegisterUserRequestSuccessTest.
/**
* Service register user request success test.
*
* @throws Exception
* the exception
*/
@Test
@PerfTest(threads = 4, duration = 5000, warmUp = 1500)
@Required(max = 2000, average = 1200, percentile95 = 1500, throughput = 2)
public void serviceRegisterUserRequestSuccessTest() throws Exception {
final CreateApplicationSessionRequest createApplicationSesstion = createApplicationSesstionWithRoleAnonymous();
final RegisterUserRequest serviceRequest = new RegisterUserRequest();
serviceRequest.setCountry("Sweden");
serviceRequest.setUsername(UUID.randomUUID().toString());
serviceRequest.setEmail(serviceRequest.getUsername() + "@email.com");
serviceRequest.setUserpassword("Userpassword1!");
serviceRequest.setUserType(UserType.PRIVATE);
serviceRequest.setSessionId(createApplicationSesstion.getSessionId());
final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
final DataContainer<UserAccount, Long> dataContainer = applicationManager.getDataContainer(UserAccount.class);
final List<UserAccount> allBy = dataContainer.getAllBy(UserAccount_.username, serviceRequest.getUsername());
assertEquals(1, allBy.size());
}
use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.
the class RegisterUserServiceITest method serviceRegisterUserRequestUserAlreadyExistFailureTest.
/**
* Service register user request user already exist failure test.
*
* @throws Exception
* the exception
*/
@Test
public void serviceRegisterUserRequestUserAlreadyExistFailureTest() throws Exception {
final CreateApplicationSessionRequest createApplicationSesstion = createApplicationSesstionWithRoleAnonymous();
final RegisterUserRequest serviceRequest = new RegisterUserRequest();
serviceRequest.setCountry("Sweden");
serviceRequest.setUsername(UUID.randomUUID().toString());
serviceRequest.setEmail(serviceRequest.getUsername() + "@email.com");
serviceRequest.setUserpassword("Userpassword1!");
serviceRequest.setUserType(UserType.PRIVATE);
serviceRequest.setSessionId(createApplicationSesstion.getSessionId());
final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
createApplicationSesstionWithRoleAnonymous();
final DataContainer<UserAccount, Long> dataContainer = applicationManager.getDataContainer(UserAccount.class);
final List<UserAccount> allBy = dataContainer.getAllBy(UserAccount_.username, serviceRequest.getUsername());
assertEquals(1, allBy.size());
final RegisterUserResponse errorResponse = (RegisterUserResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, errorResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.FAILURE, errorResponse.getResult());
assertEquals(RegisterUserResponse.ErrorMessage.USER_ALREADY_EXIST.toString(), errorResponse.getErrorMessage());
}
use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.
the class SetGoogleAuthenticatorCredentialServiceITest method servicesetGoogleAuthenticatorCredentialRequestSuccessTest.
/**
* Serviceset google authenticator credential request success test.
*
* @throws Exception
* the exception
*/
@Test
@PerfTest(threads = 2, duration = 4000, warmUp = 1500)
@Required(max = 3000, average = 2500, percentile95 = 2700, throughput = 1)
public void servicesetGoogleAuthenticatorCredentialRequestSuccessTest() throws Exception {
final CreateApplicationSessionRequest createApplicationSesstion = createApplicationSesstionWithRoleAnonymous();
final RegisterUserRequest serviceRequest = new RegisterUserRequest();
serviceRequest.setCountry("Sweden");
serviceRequest.setUsername(UUID.randomUUID().toString());
serviceRequest.setEmail(serviceRequest.getUsername() + "@email.com");
serviceRequest.setUserpassword("Userpassword1!");
serviceRequest.setUserType(UserType.PRIVATE);
serviceRequest.setSessionId(createApplicationSesstion.getSessionId());
final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
final DataContainer<UserAccount, Long> dataContainer = applicationManager.getDataContainer(UserAccount.class);
final List<UserAccount> allBy = dataContainer.getAllBy(UserAccount_.username, serviceRequest.getUsername());
assertEquals(1, allBy.size());
final LoginRequest loginRequest = new LoginRequest();
loginRequest.setEmail(serviceRequest.getEmail());
loginRequest.setSessionId(serviceRequest.getSessionId());
loginRequest.setUserpassword(serviceRequest.getUserpassword());
final LoginResponse loginResponse = (LoginResponse) applicationManager.service(loginRequest);
assertNotNull(EXPECT_A_RESULT, loginResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, loginResponse.getResult());
final SetGoogleAuthenticatorCredentialRequest setGoogleAuthenticatorCredentialRequest = new SetGoogleAuthenticatorCredentialRequest();
setGoogleAuthenticatorCredentialRequest.setSessionId(serviceRequest.getSessionId());
final ServiceResponse setGoogleAuthenticatorCredentialResponse = applicationManager.service(setGoogleAuthenticatorCredentialRequest);
assertNotNull(EXPECT_A_RESULT, setGoogleAuthenticatorCredentialResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, setGoogleAuthenticatorCredentialResponse.getResult());
final LogoutRequest logoutRequest = new LogoutRequest();
logoutRequest.setSessionId(serviceRequest.getSessionId());
final ServiceResponse logoutResponse = applicationManager.service(logoutRequest);
assertNotNull(EXPECT_A_RESULT, logoutResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, logoutResponse.getResult());
}
use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.
the class BallotChartsPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<ViewRiksdagenVoteDataBallotSummary, RiksdagenVoteDataBallotEmbeddedId> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenVoteDataBallotSummary.class);
final DataContainer<ViewRiksdagenVoteDataBallotPartySummary, RiksdagenVoteDataBallotPartyEmbeddedId> dataPartyContainer = getApplicationManager().getDataContainer(ViewRiksdagenVoteDataBallotPartySummary.class);
final List<ViewRiksdagenVoteDataBallotSummary> ballots = dataContainer.findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotSummary.class, ViewRiksdagenVoteDataBallotSummary_.embeddedId, RiksdagenVoteDataBallotEmbeddedId.class, RiksdagenVoteDataBallotEmbeddedId_.ballotId, pageId);
final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotList = dataPartyContainer.findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotPartySummary.class, ViewRiksdagenVoteDataBallotPartySummary_.embeddedId, RiksdagenVoteDataBallotPartyEmbeddedId.class, RiksdagenVoteDataBallotPartyEmbeddedId_.ballotId, pageId);
if (!ballots.isEmpty()) {
getBallotMenuItemFactory().createBallotMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, CHARTS);
final TabSheet tabsheet = new TabSheet();
tabsheet.setWidth(100, Unit.PERCENTAGE);
tabsheet.setHeight(100, Unit.PERCENTAGE);
panelContent.addComponent(tabsheet);
panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);
Collections.sort(ballots, (Comparator<ViewRiksdagenVoteDataBallotSummary>) (o1, o2) -> (o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern()).compareTo(o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern()));
for (final ViewRiksdagenVoteDataBallotSummary viewRiksdagenVoteDataBallotSummary : ballots) {
final HorizontalLayout tabContent = new HorizontalLayout();
tabContent.setWidth(100, Unit.PERCENTAGE);
tabContent.setHeight(100, Unit.PERCENTAGE);
final Tab tab = tabsheet.addTab(tabContent);
ballotChartDataManager.createChart(tab, tabContent, viewRiksdagenVoteDataBallotSummary);
}
final Map<String, List<ViewRiksdagenVoteDataBallotPartySummary>> concernIssuePartyBallotSummaryMap = createIssueConcernMap(partyBallotList);
for (final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotSummaryList : concernIssuePartyBallotSummaryMap.values()) {
final HorizontalLayout tabContent = new HorizontalLayout();
tabContent.setWidth(100, Unit.PERCENTAGE);
tabContent.setHeight(100, Unit.PERCENTAGE);
final Tab tab = tabsheet.addTab(tabContent);
ballotChartDataManager.createChart(tab, tabContent, partyBallotSummaryList);
}
panel.setCaption(new StringBuilder().append(NAME).append("::").append(BALLOT).append(pageId).toString());
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_BALLOT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
}
return panelContent;
}
Aggregations