use of org.springframework.ui.ExtendedModelMap in project Asqatasun by Asqatasun.
the class PageListControllerTest method testDisplayPageListWithWrongAuditId.
/**
* if the id cannot be converted as Long, the ForbiddenPageException is
* caught.
*
* @throws Exception
*/
public void testDisplayPageListWithWrongAuditId() throws Exception {
System.out.println("testDisplayPageListWithWrongAuditId");
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(TgolKeyStore.AUDIT_ID_KEY, "wrongId");
try {
instance.displayPageList(request, new MockHttpServletResponse(), new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fbe) {
assertTrue(StringUtils.equals("java.lang.NumberFormatException: For input string: \"wrongId\"", fbe.getCause().toString()));
}
}
use of org.springframework.ui.ExtendedModelMap in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditPageSetUpWithUnauthorisedFunctionality.
public void testDisplayPageAuditPageSetUpWithUnauthorisedFunctionality() {
System.out.println("testDisplayPageAuditPageSetUpWithUnauthorisedFunctionality");
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(2, "Contract1");
setUpEmptyViewFunctionalityBindingMap();
// regarding the viewFunctionalityBindingMap. An exception is caught
try {
instance.displayPageAuditSetUp("2", null, null, new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
}
use of org.springframework.ui.ExtendedModelMap in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditSiteSetUpWithWrongContractId.
public void testDisplayPageAuditSiteSetUpWithWrongContractId() {
System.out.println("testDisplayPageAuditSiteSetUpWithWrongContractId");
// set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
// the contract Id cannot be converted as a Long. An exception is caught
try {
instance.displaySiteAuditSetUp("Not a number", null, null, new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
}
use of org.springframework.ui.ExtendedModelMap in project Asqatasun by Asqatasun.
the class ContractControllerTest method testDisplayContractExpiredPage_4args.
public void testDisplayContractExpiredPage_4args() {
System.out.println("displayContractExpiredPage");
setUpUserDataService(true);
setUpContractDataService(0);
setUpActDataService(0, 0, 0, 0, 0);
setUpLocaleResolver();
setUpActionHandler(0);
setUpMockAuthenticationContext();
// contractId cannot be converted as a long, the ForbiddenUserException
// is caught
String contractId = "wrongId";
HttpServletRequest request = null;
HttpServletResponse response = null;
Model model = new ExtendedModelMap();
try {
instance.displayContractPage(contractId, request, response, model);
// if the exception is not caught, the test is on error
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
try {
instance.displayContractPage(contractId, request, response, model);
// if the exception is not caught, the test is on error
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
}
use of org.springframework.ui.ExtendedModelMap in project Asqatasun by Asqatasun.
the class UserManagementControllerTest method testAddUserAdminPage.
/**
* Test of addUserAdminPage method, of class UserManagementController.
*/
public void testAddUserAdminPage() {
System.out.println("addUserAdminPage");
instance = new UserManagementController();
setUpMockRoleDataService();
setUpMockUserDataService(false, false, false, false, false);
setUpMockAuthenticationContext();
instance.setUserDataService(mockUserDataService);
HttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest();
Model model = new ExtendedModelMap();
String result = instance.displayAddUserAdminPage(request, response, model);
assertEquals(TgolKeyStore.ADD_USER_VIEW_NAME, result);
assertEquals(1, model.asMap().size());
CreateUserCommand cuc = ((CreateUserCommand) model.asMap().get(TgolKeyStore.CREATE_USER_COMMAND_KEY));
assertNotNull(cuc);
assertFalse(cuc.getActivated());
assertFalse(cuc.getAdmin());
assertNull(cuc.getEmail());
assertEquals("http://", cuc.getSiteUrl());
assertNull(cuc.getPhoneNumber());
assertNull(cuc.getLastName());
assertNull(cuc.getFirstName());
assertNull(cuc.getPassword());
assertNull(cuc.getConfirmPassword());
}
Aggregations