use of org.asqatasun.webapp.exception.ForbiddenPageException 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.asqatasun.webapp.exception.ForbiddenPageException 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.asqatasun.webapp.exception.ForbiddenPageException in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditPageSetUpWithWrongContractId.
public void testDisplayPageAuditPageSetUpWithWrongContractId() {
System.out.println("testDisplayPageAuditPageSetUpWithWrongContractId");
// set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
// the contract Id cannot be converted as a Long. An exception is caught
try {
instance.displayPageAuditSetUp("Not a number", null, null, new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
}
use of org.asqatasun.webapp.exception.ForbiddenPageException in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method testDisplayPageAuditUploadSetUpWithWrongContractId.
public void testDisplayPageAuditUploadSetUpWithWrongContractId() {
System.out.println("testDisplayPageAuditUploadSetUpWithWrongContractId");
// set-up
setUpMockUserDataServiceAndUser();
setUpMockAuthenticationContext();
setUpMockContractDataService(1, "Contract1");
// the contract Id cannot be converted as a Long. An exception is caught
try {
instance.displayUploadAuditSetUp("Not a number", null, null, new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fue) {
assertTrue(true);
}
}
use of org.asqatasun.webapp.exception.ForbiddenPageException in project Asqatasun by Asqatasun.
the class PageListControllerTest method testDisplayPageListWithUnknownAuditId.
/**
* The mockWebResourceDataService contains only 2 WebResource. One has
* Id=1 and is a Page instance, the second has Id=2 and is a Site instance.
* If a webresource with an id different from 1 or 2 is requested, the
* ForbiddenPageException is caught
*
* @throws Exception
*/
public void testDisplayPageListWithUnknownAuditId() throws Exception {
System.out.println("testDisplayPageListWithUnknownAuditId");
setUpMockAuditDataService(UNKNOWN_AUDIT_ID);
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(TgolKeyStore.AUDIT_ID_KEY, String.valueOf(UNKNOWN_AUDIT_ID));
try {
instance.displayPageList(request, new MockHttpServletResponse(), new ExtendedModelMap());
assertTrue(false);
} catch (ForbiddenPageException fbe) {
// The auditDataService catch the NoResultException and return null.
// Then if the audit is null, a ForbiddenPageException is caught
assertTrue(true);
}
}
Aggregations