ContractController extends AbstractController { @RequestMapping(value=TgolKeyStore.CONTRACT_URL, method=RequestMethod.GET) @Secured({TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY}) public String displayContractPage ( @RequestParam(TgolKeyStore.CONTRACT_ID_KEY) String contractId, HttpServletRequest request, Model model) { Long contractIdValue; try { contractIdValue = Long.valueOf(contractId); } catch (NumberFormatException nfe) { throw new ForbiddenPageException(getCurrentUser()); } if (!isUserOwnedContract(contractIdValue)) { throw new ForbiddenUserException(getCurrentUser()); } return displayContractPage(request, model, contractIdValue); } @Autowired  ContractController(ContractDataService contractDataService,
                              DetailedContractInfoFactory detailedContractInfoFactory,
                              LocaleResolver localeResolver); @RequestMapping(value=TgolKeyStore.CONTRACT_URL, method=RequestMethod.GET) @Secured({TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY}) String displayContractPage(
            @RequestParam(TgolKeyStore.CONTRACT_ID_KEY) String contractId,
            HttpServletRequest request,
            Model model);  }
@Test public void testDisplayContractPage_4args() { setUpMockUserAndAuthenticationContext(); setUpContractDataService(false); Model model = new ExtendedModelMap(); assertThrows(ForbiddenPageException.class, () -> instance.displayContractPage("wrongId", null, model)); String result = instance.displayContractPage("1", null, model); assertEquals(TgolKeyStore.CONTRACT_VIEW_NAME, result); assertNull(model.getAttribute(DISPLAY_RESULT_TREND_KEY)); assertNull(model.getAttribute(CONTRACT_WITH_MANUAL_AUDIT_KEY)); verifyMockContractDataService(); }
@Test public void testDisplayContractExpiredPage_4args() { setUpMockUserAndAuthenticationContext(); setUpContractDataService(true); assertThrows(ForbiddenUserException.class, () -> instance.displayContractPage("1", null, new ExtendedModelMap())); }