Search in sources :

Example 61 with DataContainer

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());
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 62 with DataContainer

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());
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Required(org.databene.contiperf.Required) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest) PerfTest(org.databene.contiperf.PerfTest)

Example 63 with DataContainer

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());
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 64 with DataContainer

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());
}
Also used : ServiceResponse(com.hack23.cia.service.api.action.common.ServiceResponse) LoginResponse(com.hack23.cia.service.api.action.application.LoginResponse) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) SetGoogleAuthenticatorCredentialRequest(com.hack23.cia.service.api.action.user.SetGoogleAuthenticatorCredentialRequest) LogoutRequest(com.hack23.cia.service.api.action.application.LogoutRequest) LoginRequest(com.hack23.cia.service.api.action.application.LoginRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Required(org.databene.contiperf.Required) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest) PerfTest(org.databene.contiperf.PerfTest)

Example 65 with DataContainer

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;
}
Also used : RiksdagenVoteDataBallotPartyEmbeddedId_(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotPartyEmbeddedId_) PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Panel(com.vaadin.ui.Panel) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) VerticalLayout(com.vaadin.ui.VerticalLayout) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Secured(org.springframework.security.access.annotation.Secured) ViewRiksdagenVoteDataBallotSummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotSummary) ViewRiksdagenVoteDataBallotPartySummary_(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary_) ViewAction(com.hack23.cia.web.impl.ui.application.action.ViewAction) Map(java.util.Map) ViewRiksdagenVoteDataBallotSummary_(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotSummary_) BallotChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.BallotChartDataManager) ContentRatio(com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio) Tab(com.vaadin.ui.TabSheet.Tab) MenuBar(com.vaadin.ui.MenuBar) RiksdagenVoteDataBallotEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotEmbeddedId) RiksdagenVoteDataBallotPartyEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotPartyEmbeddedId) LabelFactory(com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Component(org.springframework.stereotype.Component) Layout(com.vaadin.ui.Layout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TabSheet(com.vaadin.ui.TabSheet) RiksdagenVoteDataBallotEmbeddedId_(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotEmbeddedId_) Comparator(java.util.Comparator) ViewRiksdagenVoteDataBallotPartySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary) Unit(com.vaadin.server.Sizeable.Unit) Collections(java.util.Collections) RiksdagenVoteDataBallotPartyEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotPartyEmbeddedId) ViewRiksdagenVoteDataBallotPartySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Tab(com.vaadin.ui.TabSheet.Tab) ViewRiksdagenVoteDataBallotSummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotSummary) TabSheet(com.vaadin.ui.TabSheet) VerticalLayout(com.vaadin.ui.VerticalLayout) ArrayList(java.util.ArrayList) List(java.util.List) RiksdagenVoteDataBallotEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotEmbeddedId) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

VerticalLayout (com.vaadin.ui.VerticalLayout)75 Secured (org.springframework.security.access.annotation.Secured)75 ViewRiksdagenParty (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty)19 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)17 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)15 ViewRiksdagenPolitician (com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)13 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)13 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)13 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)13 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)13 Test (org.junit.Test)13 ViewRiksdagenMinistry (com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenMinistry)11 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)11 DocumentElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement)10 PersonData (com.hack23.cia.model.external.riksdagen.person.impl.PersonData)10 PerfTest (org.databene.contiperf.PerfTest)10 DocumentStatusContainer (com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer)8 ViewRiksdagenPartySummary (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary)7 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)7 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)7