src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
GenericQuestionApplicationController { @PostMapping(params = "edit") public String edit(@PathVariable long applicationId, @PathVariable long questionId, UserResource user) { questionStatusRestService.markAsInComplete(questionId, applicationId, getUsersProcessRole(applicationId, user).getId()).getSuccess(); return redir... | @Test public void edit() throws Exception { ProcessRoleResource userProcessRole = newProcessRoleResource() .withRole(COLLABORATOR) .withUser(loggedInUser) .build(); when(userRestService.findProcessRole(loggedInUser.getId(), applicationId)).thenReturn(restSuccess(userProcessRole)); when(questionStatusRestService.markAsI... |
GenericQuestionApplicationController { @PostMapping(params = "uploadTemplateDocument") public String uploadTemplateDocument(@ModelAttribute(name = "form") GenericQuestionApplicationForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, @PathVariable long ap... | @Test public void uploadTemplateDocument() throws Exception { GenericQuestionApplicationViewModel viewModel = mock(GenericQuestionApplicationViewModel.class); ApplicantQuestionResource applicantQuestion = mock(ApplicantQuestionResource.class); when(applicantRestService.getQuestion(loggedInUser.getId(), applicationId, q... |
GenericQuestionApplicationController { @PostMapping(params = "removeTemplateDocument") public String removeTemplateDocument(@ModelAttribute(name = "form") GenericQuestionApplicationForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, @RequestParam("removeTemplateDocum... | @Test public void removeTemplateDocument() throws Exception { long fileEntryId = 10L; GenericQuestionApplicationViewModel viewModel = mock(GenericQuestionApplicationViewModel.class); ApplicantQuestionResource applicantQuestion = mock(ApplicantQuestionResource.class); when(applicantRestService.getQuestion(loggedInUser.g... |
GenericQuestionApplicationController { @PostMapping(params = "uploadAppendix") public String uploadAppendix(@ModelAttribute(name = "form") GenericQuestionApplicationForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, @PathVariable long applicationId, @Pa... | @Test public void uploadAppendix() throws Exception { GenericQuestionApplicationViewModel viewModel = mock(GenericQuestionApplicationViewModel.class); ApplicantQuestionResource applicantQuestion = mock(ApplicantQuestionResource.class); when(applicantRestService.getQuestion(loggedInUser.getId(), applicationId, questionI... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<QuestionResource> getPreviousQuestion(final Long questionId) { return find(getQuestionSupplier(questionId)).andOnSuccess(question -> { Question previousQuestion = null; if (question != null) { previousQuesti... | @Test public void getPreviousQuestionTest() throws Exception { Question question = newQuestion().withCompetitionAndSectionAndPriority(newCompetition().build(), newSection().build(), 2).build(); Question previousQuestion = newQuestion().withCompetitionAndSectionAndPriority(newCompetition().build(), newSection().build(),... |
GenericQuestionApplicationController { @PostMapping(params = "removeAppendix") public String removeAppendix(@ModelAttribute(name = "form") GenericQuestionApplicationForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, @RequestParam("removeAppendix") long fileEntryId, ... | @Test public void removeAppendix() throws Exception { long fileEntryId = 10L; GenericQuestionApplicationViewModel viewModel = mock(GenericQuestionApplicationViewModel.class); ApplicantQuestionResource applicantQuestion = mock(ApplicantQuestionResource.class); when(applicantRestService.getQuestion(loggedInUser.getId(), ... |
GenericQuestionApplicationModelPopulator { public GenericQuestionApplicationViewModel populate(ApplicantQuestionResource applicantQuestion) { Map<FormInputType, ApplicantFormInputResource> formInputs = applicantQuestion.getApplicantFormInputs() .stream() .collect(toMap(input -> input.getFormInput().getType(), Function.... | @Test public void populate() { ZonedDateTime now = ZonedDateTime.now(); ApplicantQuestionResource applicantQuestion = newApplicantQuestionResource() .withQuestion( newQuestionResource() .withQuestionNumber("1") .withDescription("desc") .withShortName("short") .withName("name") .withQuestionSetupType(QuestionSetupType.A... |
GenericQuestionApplicationFormPopulator { public GenericQuestionApplicationForm populate(GenericQuestionApplicationForm form, ApplicantQuestionResource applicantQuestion) { Optional<ApplicantFormInputResource> applicantFormInput = applicantQuestion.getApplicantFormInputs().stream() .filter(input -> input.getFormInput()... | @Test public void populate() { String value = "Two words"; ApplicantQuestionResource applicantQuestion = newApplicantQuestionResource() .withApplicantFormInputs(asList( newApplicantFormInputResource() .withFormInput(newFormInputResource() .withType(FormInputType.TEXTAREA) .withGuidanceAnswer("Guidance") .withGuidanceTi... |
GenericQuestionApplicationFormValidator { private void validateTextArea(GenericQuestionApplicationForm form, BindingResult bindingResult) { if (form.isTextAreaActive() && form.getAnswer().trim().length() <= 0) { bindingResult.rejectValue("answer", "validation.field.please.enter.some.text"); } } void validate(GenericQu... | @Test public void validateTextArea() { GenericQuestionApplicationForm form = new GenericQuestionApplicationForm(); form.setAnswer(""); form.setTextAreaActive(true); form.setMultipleChoiceOptionsActive(false); validator.validate(form, bindingResult); assertTrue(bindingResult.hasErrors()); Assert.assertEquals(1, bindingR... |
GenericQuestionApplicationFormValidator { private void validateMultipleChoiceOptions(GenericQuestionApplicationForm form, BindingResult bindingResult) { if (form.isMultipleChoiceOptionsActive() && form.getMultipleChoiceOptionId() == null) { bindingResult.rejectValue("multipleChoiceOptionId", "validation.multiple.choice... | @Test public void validateMultipleChoiceOptions() { GenericQuestionApplicationForm form = new GenericQuestionApplicationForm(); form.setAnswer(""); form.setTextAreaActive(false); form.setMultipleChoiceOptionsActive(true); validator.validate(form, bindingResult); assertTrue(bindingResult.hasErrors()); Assert.assertEqual... |
ApplicationAjaxController { @PostMapping("/{competitionId}/saveFormElement") @ResponseBody public JsonNode saveFormElement(@RequestParam("formInputId") String inputIdentifier, @RequestParam("value") String value, @RequestParam("multipleChoiceOptionId") Long multipleChoiceOptionId, @PathVariable(APPLICATION_ID) Long app... | @Test public void testSaveFormElement() throws Exception { String value = "Form Input " + formInputId + " Response"; mockMvc.perform( post("/application/" + application.getId().toString() + "/form/123/saveFormElement") .param("formInputId", formInputId.toString()) .param("fieldName", "formInput[" + formInputId + "]") .... |
ApplicationSectionController { @SecuredBySpring(value = "TODO", description = "TODO") @PreAuthorize("hasAnyAuthority('applicant', 'support', 'innovation_lead', 'ifs_administrator', 'comp_admin', 'project_finance', 'stakeholder', 'external_finance', 'knowledge_transfer_adviser')") @GetMapping("/{sectionType}/{organisati... | @Test public void redirectToSectionManagement() throws Exception { when(applicationRestService.getApplicationById(APPLICATION_ID)).thenReturn(restSuccess(APPLICATION)); when(sectionRestService.getSectionsByCompetitionIdAndType(COMPETITION_ID, SECTION_TYPE)).thenReturn(restSuccess(singletonList(SECTION))); when(applicat... |
ApplicationSectionController { @SecuredBySpring(value = "TODO", description = "TODO") @PreAuthorize("hasAuthority('applicant')") @GetMapping("/{sectionType}") public String redirectToSection(@PathVariable SectionType sectionType, @PathVariable long applicationId, UserResource user) { ApplicationResource application = a... | @Test public void redirectToSection() throws Exception { when(applicationRestService.getApplicationById(APPLICATION_ID)).thenReturn(restSuccess(APPLICATION)); when(sectionRestService.getSectionsByCompetitionIdAndType(COMPETITION_ID, SECTION_TYPE)).thenReturn(restSuccess(singletonList(SECTION))); when(userRestService.fi... |
ApplicationSectionController { @SecuredBySpring(value = "TODO", description = "TODO") @PreAuthorize("hasAuthority('applicant')") @GetMapping(SECTION_URL + "{sectionId}") public String getSectionApplicant(@PathVariable long applicationId, @PathVariable long sectionId, UserResource user) { SectionResource section = secti... | @Test public void getSectionApplicant() throws Exception { when(applicationRestService.getApplicationById(APPLICATION_ID)).thenReturn(restSuccess(APPLICATION)); when(sectionRestService.getById(SECTION_ID)).thenReturn(restSuccess(SECTION)); when(userRestService.findProcessRole(loggedInUser.getId(), APPLICATION_ID)).then... |
ApplicationSectionController { @SecuredBySpring(value = "ApplicationSectionController", description = "Internal users can access the sections in the 'Your project Finances'") @PreAuthorize("hasAnyAuthority('support', 'innovation_lead', 'ifs_administrator', 'comp_admin', 'project_finance', 'stakeholder')") @GetMapping(S... | @Test public void getSectionInternalUser() throws Exception { when(applicationRestService.getApplicationById(APPLICATION_ID)).thenReturn(restSuccess(APPLICATION)); when(sectionRestService.getById(SECTION_ID)).thenReturn(restSuccess(SECTION)); when(userRestService.findProcessRole(loggedInUser.getId(), APPLICATION_ID)).t... |
YourProjectLocationFormPopulator { public YourProjectLocationForm populate(long applicationId, long organisationId) { ApplicationFinanceResource applicationFinance = applicationFinanceRestService.getApplicationFinance(applicationId, organisationId).getSuccess(); String postcode = applicationFinance.getWorkPostcode(); S... | @Test public void populate() { long applicationId = 123L; long organisationId = 456L; String postcode = "S2 5AB"; when(applicationFinanceRestServiceMock.getApplicationFinance(applicationId, organisationId)). thenReturn(restSuccess(newApplicationFinanceResource().withWorkPostcode(postcode).build())); YourProjectLocation... |
YourProjectLocationController extends AsyncAdaptor { @GetMapping @AsyncMethod @PreAuthorize("hasAnyAuthority('applicant', 'support', 'innovation_lead', 'ifs_administrator', 'comp_admin', 'project_finance', 'stakeholder', 'external_finance', 'knowledge_transfer_adviser')") @SecuredBySpring(value = "VIEW_PROJECT_LOCATION... | @Test public void viewPage() throws Exception { assertViewPageSuccessful(false); } |
YourProjectLocationController extends AsyncAdaptor { @PostMapping("/auto-save") @PreAuthorize("hasAuthority('applicant')") @SecuredBySpring(value = "UPDATE_PROJECT_LOCATION", description = "Applicants can update their project location") public @ResponseBody JsonNode autosave( @PathVariable("applicationId") long applica... | @Test public void autosave() throws Exception { assertAutosavePostcodeSuccessful(postcode); } |
YourProjectLocationController extends AsyncAdaptor { @PostMapping(params = "mark-as-complete") @PreAuthorize("hasAuthority('applicant')") @SecuredBySpring(value = "MARK_PROJECT_LOCATION_AS_COMPLETE", description = "Applicants can mark their project location as complete") public String markAsComplete( @PathVariable("app... | @Test public void markAsComplete() throws Exception { assertMarkAsCompleteSuccessful(postcode); } |
YourProjectLocationController extends AsyncAdaptor { @PostMapping(params = "mark-as-incomplete") @PreAuthorize("hasAuthority('applicant')") @SecuredBySpring(value = "MARK_PROJECT_LOCATION_AS_INCOMPLETE", description = "Applicants can mark their project location as incomplete") public String markAsIncomplete( @PathVaria... | @Test public void markAsIncomplete() throws Exception { ProcessRoleResource processRole = newProcessRoleResource().build(); when(userRestServiceMock.findProcessRole(loggedInUser.getId(), applicationId)).thenReturn(restSuccess(processRole)); String viewUrl = String.format("redirect:/application/%d/form/your-project-loca... |
Horizon2020CostsSaver { public ServiceResult<Void> save(Horizon2020CostsForm form, long applicationId, long organisationId) { ApplicationFinanceResource applicationFinance = applicationFinanceRestService.getFinanceDetails(applicationId, organisationId).getSuccess(); saveLabour(form, applicationFinance); saveOverhead(fo... | @Test public void save() { LabourCost workingDays = newLabourCost() .withGrossEmployeeCost(BigDecimal.ZERO) .withDescription(WORKING_DAYS_PER_YEAR) .withLabourDays(1) .build(); Overhead overhead = newOverhead() .withRateType(OverheadRateType.NONE) .build(); ApplicationFinanceResource finance = newApplicationFinanceReso... |
Horizon2020CostsController extends AsyncAdaptor { @PostMapping @AsyncMethod public String saveYourProjectCosts(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long organisationId, @PathVariable long sectionId, @ModelAttribute("form") Horizon2020CostsForm form) { saver.save(form, applicat... | @Test public void saveYourProjectCosts() throws Exception { when(saver.save(any(Horizon2020CostsForm.class), eq(APPLICATION_ID), eq(ORGANISATION_ID))).thenReturn(serviceSuccess()); mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/horizon-2020-costs/organisation/{organisationId}/section/{sectionId}", AP... |
Horizon2020CostsController extends AsyncAdaptor { @PostMapping(params = "edit") public String edit(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long organisationId, @PathVariable long sectionId) { sectionStatusRestService.markAsInComplete(sectionId, applicationId, getProcessRoleId(app... | @Test public void edit() throws Exception { when(userRestService.findProcessRole(APPLICATION_ID, getLoggedInUser().getId())) .thenReturn(restSuccess(newProcessRoleResource().withId(PROCESS_ROLE_ID).build())); when(sectionStatusRestService.markAsInComplete(SECTION_ID, APPLICATION_ID, PROCESS_ROLE_ID)).thenReturn(restSuc... |
Horizon2020CostsController extends AsyncAdaptor { @PostMapping(params = "complete") @AsyncMethod public String complete(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long organisationId, @PathVariable long sectionId, @Valid @ModelAttribute("form") Horizon2020CostsForm form, BindingResu... | @Test public void complete() throws Exception { ProcessRoleResource processRole = newProcessRoleResource().withId(PROCESS_ROLE_ID).build(); when(saver.save(any(Horizon2020CostsForm.class), eq(APPLICATION_ID), eq(ORGANISATION_ID))).thenReturn(serviceSuccess()); when(userRestService.findProcessRole(APPLICATION_ID, getLog... |
Horizon2020CostsFormPopulator { public Horizon2020CostsForm populate(long applicationId, long organisationId) { ApplicationFinanceResource applicationFinance = applicationFinanceRestService.getFinanceDetails(applicationId, organisationId).getSuccess(); Horizon2020CostsForm form = new Horizon2020CostsForm(); form.setLab... | @Test public void populate() { ApplicationFinanceResource finance = newApplicationFinanceResource().withIndustrialCosts().build(); when(applicationFinanceRestService.getFinanceDetails(APPLICATION_ID, ORGANISATION_ID)).thenReturn(restSuccess(finance)); Horizon2020CostsForm form = populator.populate(APPLICATION_ID, ORGAN... |
CommonYourFinancesViewModelPopulator { public CommonYourProjectFinancesViewModel populate(long organisationId, long applicationId, long sectionId, UserResource user) { ApplicationResource application = applicationRestService.getApplicationById(applicationId).getSuccess(); CompetitionResource competition = competitionRe... | @Test public void populate() { boolean internalUser = false; List<Long> sectionsMarkedAsComplete = asList(111L, 333L); ApplicationState applicationState = ApplicationState.OPENED; CompetitionStatus competitionState = CompetitionStatus.OPEN; assertViewModelPopulatedOk( internalUser, sectionsMarkedAsComplete, application... |
YourFundingSaver extends AbstractYourFundingSaver { public ServiceResult<Void> save(long applicationId, long organisationId, AbstractYourFundingAmountForm<? extends BaseOtherFundingRowForm> form) { ApplicationFinanceResource finance = applicationFinanceRestService.getFinanceDetails(applicationId, organisationId).getSuc... | @Test public void save() { OtherFunding otherFunding = newOtherFunding() .withFundingSource(OtherFundingCostCategory.OTHER_FUNDING) .withOtherPublicFunding("No") .build(); ApplicationFinanceResource finance = newApplicationFinanceResource() .withFinanceOrganisationDetails(asMap( FinanceRowType.FINANCE, newExcludedCostC... |
YourFundingController { @GetMapping @SecuredBySpring(value = "VIEW_YOUR_FUNDING_SECTION", description = "Internal users and kta can access the sections in the 'Your project finances'") @PreAuthorize("hasAnyAuthority('applicant', 'support', 'innovation_lead', 'ifs_administrator', 'comp_admin', 'project_finance', 'stakeh... | @Test public void viewYourFunding() throws Exception { YourFundingViewModel viewModel = mockUnlockedViewModel(); mockMvc.perform(get(APPLICATION_BASE_URL + "{applicationId}/form/your-funding/organisation/{organisationId}/section/{sectionId}", APPLICATION_ID, ORGANISATION_ID, SECTION_ID)) .andExpect(model().attribute("m... |
YourFundingController { @PostMapping(params = "grantClaimPercentage") public String saveYourFunding(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @PathVariable long organisationId, @ModelAttribute("form") YourFundingPercentageForm form) { saver.save(applicationId, organ... | @Test public void saveYourFunding() throws Exception { when(saver.save(eq(APPLICATION_ID), eq(ORGANISATION_ID), any(YourFundingPercentageForm.class))).thenReturn(serviceSuccess()); mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-funding/organisation/{organisationId}/section/{sectionId}", APPLICAT... |
YourFundingController { @PostMapping(params = "edit") public String edit(UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @PathVariable long organisationId) { sectionStatusRestService.markAsInComplete(sectionId, applicationId, getProcessRoleId(applicationId, user.getId())).getSuccess()... | @Test public void edit() throws Exception { YourFundingViewModel viewModel = mockUnlockedViewModel(); when(userRestService.findProcessRole(APPLICATION_ID, getLoggedInUser().getId())) .thenReturn(restSuccess(newProcessRoleResource().withId(PROCESS_ROLE_ID).build())); when(sectionStatusRestService.markAsInComplete(SECTIO... |
YourFundingController { @PostMapping(params = {"complete", "grantClaimPercentage"}) public String complete(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @PathVariable long organisationId, @ModelAttribute("form") YourFundingPercentageForm form, BindingResult bindingResul... | @Test public void complete() throws Exception { long competitionId = 1l; ApplicationResource applicationResource = newApplicationResource() .withCompetition(competitionId) .build(); CompetitionApplicationConfigResource competitionApplicationConfigResource = newCompetitionApplicationConfigResource().build(); when(saver.... |
YourFundingController { @PostMapping(params = {"add_cost", "grantClaimPercentage"}) public String addFundingRowFormPost(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @PathVariable long organisationId, @ModelAttribute("form") YourFundingPercentageForm form) { saver.addOt... | @Test public void addFundingRowFormPost() throws Exception { YourFundingViewModel viewModel = mockUnlockedViewModel(); mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-funding/organisation/{organisationId}/section/{sectionId}", APPLICATION_ID, ORGANISATION_ID, SECTION_ID) .param("add_cost", "true"... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<QuestionResource> getPreviousQuestionBySection(final Long sectionId) { return sectionService.getById(sectionId).andOnSuccess(section -> { if (section.getParentSection() != null) { Optional<SectionResource> p... | @Test public void getPreviousQuestionBySectionTest() throws Exception { Section currentSection = newSection().withCompetitionAndPriorityAndParent(newCompetition().build(), 1, newSection().build()).build(); SectionResource currentSectionResource = newSectionResource().withCompetitionAndPriorityAndParent(newCompetition()... |
YourFundingController { @PostMapping(params = {"remove_cost", "grantClaimPercentage"}) public String removeFundingRowFormPost(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @PathVariable long organisationId, @ModelAttribute("form") YourFundingPercentageForm form, @Reques... | @Test public void removeFundingRowFormPost() throws Exception { YourFundingViewModel viewModel = mockUnlockedViewModel(); String rowToRemove = "5"; mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-funding/organisation/{organisationId}/section/{sectionId}", APPLICATION_ID, ORGANISATION_ID, SECTION_... |
YourFundingController { @PostMapping("remove-row/{rowId}") public @ResponseBody JsonNode ajaxRemoveRow(@PathVariable String rowId) { saver.removeOtherFundingRow(rowId); return new ObjectMapper().createObjectNode(); } @GetMapping @SecuredBySpring(value = "VIEW_YOUR_FUNDING_SECTION", description = "Internal users and kt... | @Test public void ajaxRemoveRow() throws Exception { String costId = "123"; mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-funding/organisation/{organisationId}/section/{sectionId}/remove-row/{rowId}", APPLICATION_ID, ORGANISATION_ID, SECTION_ID, costId)) .andExpect(status().isOk()); verify(save... |
YourFundingController { @PostMapping("add-row") public String ajaxAddRow(Model model, @PathVariable long applicationId) { ApplicationResource applicationResource = applicationRestService.getApplicationById(applicationId).getSuccess(); CompetitionResource competitionResource = competitionRestService.getCompetitionById(a... | @Test public void ajaxAddRow() throws Exception { String rowId = "123"; OtherFundingRowForm row = new OtherFundingRowForm(); row.setCostId(Long.valueOf(rowId)); Long competitionId = 4L; ApplicationResource application = newApplicationResource().withCompetition(competitionId).build(); when(applicationRestService.getAppl... |
YourFundingFormPopulator extends AbstractYourFundingFormPopulator { public AbstractYourFundingForm populateForm(long applicationId, long organisationId) { CompetitionResource competitionResource = competitionRestService.getCompetitionForApplication(applicationId).getSuccess(); ApplicationFinanceResource finance = appli... | @Test public void populate() { YourFundingPercentageForm form = (YourFundingPercentageForm) service.populateForm(APPLICATION_ID, organisation.getId()); assertEquals(form.getRequestingFunding(), true); assertEquals(form.getGrantClaimPercentage(), BigDecimal.valueOf(100)); assertEquals(form.getOtherFunding(), true); asse... |
YourFundingViewModelPopulator { public YourFundingViewModel populate(long applicationId, long sectionId, long organisationId, UserResource user) { if (user.isInternalUser() || user.hasRole(Role.EXTERNAL_FINANCE) || user.hasRole(Role.KNOWLEDGE_TRANSFER_ADVISER)) { return populateManagement(applicationId, sectionId, orga... | @Test public void populate() { CompetitionResource competition = newCompetitionResource().build(); SectionResource sectionResource = newSectionResource() .withId(SECTION_ID) .withChildSections(Collections.emptyList()) .withCompetition(competition.getId()) .withType(SectionType.FUNDING_FINANCES).build(); UserResource us... |
YourFundingViewModelPopulator { private ManagementYourFundingViewModel populateManagement(long applicationId, long sectionId, long organisationId, UserResource user) { ApplicationResource application = applicationRestService.getApplicationById(applicationId).getSuccess(); CompetitionResource competition = competitionRe... | @Test public void populateManagement() { long organisationId = 3L; long competitionId = 4L; CompetitionResource competition = newCompetitionResource().build(); OrganisationResource organisation = newOrganisationResource().withOrganisationType(OrganisationTypeEnum.BUSINESS.getId()).build(); when(applicationRestService.g... |
YourFundingFormValidator extends AbstractYourFundingFormValidator { public void validate(AbstractYourFundingForm form, Errors errors, UserResource user, long applicationId) { ApplicationResource applicationResource = applicationRestService.getApplicationById(applicationId).getSuccess(); CompetitionApplicationConfigReso... | @Test public void validate() { String unsavedId = generateUnsavedRowId(); YourFundingPercentageForm form = new YourFundingPercentageForm(); form.setRequestingFunding(true); form.setGrantClaimPercentage(BigDecimal.valueOf(0)); long competitionId = 1l; ApplicationResource applicationResource = newApplicationResource() .w... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<List<QuestionResource>> getQuestionsBySectionIdAndType( Long sectionId, QuestionType type) { return getSection(sectionId).andOnSuccessReturn(section -> questionsOfType(section, type)); } @Override ServiceRe... | @Test public void getQuestionsBySectionIdAndTypeTest() { Question child1CostQuestion = newQuestion().withQuestionType(QuestionType.COST).build(); Question child1OtherQuestion = newQuestion().withQuestionType(QuestionType.GENERAL).build(); Section childSection1 = newSection().withQuestions(asList(child1CostQuestion, chi... |
YourProjectCostsController extends AsyncAdaptor { @GetMapping @PreAuthorize("hasAnyAuthority('applicant', 'support', 'innovation_lead', 'ifs_administrator', 'comp_admin', 'project_finance', 'stakeholder', 'external_finance', 'knowledge_transfer_adviser')") @SecuredBySpring(value = "VIEW_PROJECT_COSTS", description = "A... | @Test public void viewYourProjectCosts() throws Exception { YourProjectCostsViewModel viewModel = mockViewModel(); OrganisationResource organisationResource = newOrganisationResource() .withId(ORGANISATION_ID) .build(); when(formPopulator.populateForm(APPLICATION_ID, ORGANISATION_ID)).thenReturn(new YourProjectCostsFor... |
YourProjectCostsController extends AsyncAdaptor { @PostMapping @AsyncMethod public String saveYourProjectCosts(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long sectionId, @ModelAttribute("form") YourProjectCostsForm form, BindingResult bindingResult) { saver.save(form, applicationId,... | @Test public void saveYourProjectCosts() throws Exception { when(saver.save(any(YourProjectCostsForm.class), eq(APPLICATION_ID), eq(getLoggedInUser()))).thenReturn(serviceSuccess()); mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-project-costs/organisation/{organisationId}/section/{sectionId}", ... |
YourProjectCostsController extends AsyncAdaptor { @PostMapping(params = "edit") public String edit(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long organisationId, @PathVariable long sectionId, @ModelAttribute("form") YourProjectCostsForm form) { sectionStatusRestService.markAsInComp... | @Test public void edit() throws Exception { when(userRestService.findProcessRole(APPLICATION_ID, getLoggedInUser().getId())) .thenReturn(restSuccess(newProcessRoleResource().withId(PROCESS_ROLE_ID).build())); when(sectionStatusRestService.markAsInComplete(SECTION_ID, APPLICATION_ID, PROCESS_ROLE_ID)).thenReturn(restSuc... |
YourProjectCostsController extends AsyncAdaptor { @PostMapping(params = "complete") @AsyncMethod public String complete(Model model, UserResource user, @PathVariable long applicationId, @PathVariable long organisationId, @PathVariable long sectionId, @Valid @ModelAttribute("form") YourProjectCostsForm form, BindingResu... | @Test public void complete() throws Exception { ProcessRoleResource processRole = newProcessRoleResource().withId(PROCESS_ROLE_ID).build(); when(saver.save(any(YourProjectCostsForm.class), eq(APPLICATION_ID), eq(getLoggedInUser()))).thenReturn(serviceSuccess()); when(userRestService.findProcessRole(APPLICATION_ID, getL... |
YourProjectCostsController extends AsyncAdaptor { @PostMapping("remove-row/{rowId}") public @ResponseBody JsonNode ajaxRemoveRow(UserResource user, @PathVariable long applicationId, @PathVariable String rowId) { saver.removeFinanceRow(rowId); return new ObjectMapper().createObjectNode(); } @GetMapping @PreAuthorize("h... | @Test public void ajaxRemoveRow() throws Exception { String costId = "123"; mockMvc.perform(post(APPLICATION_BASE_URL + "{applicationId}/form/your-project-costs/organisation/{organisationId}/section/{sectionId}/remove-row/{rowId}", APPLICATION_ID, ORGANISATION_ID, SECTION_ID, costId)) .andExpect(status().isOk()); verif... |
YourProjectCostsController extends AsyncAdaptor { @PostMapping("add-row/{rowType}") public String ajaxAddRow(Model model, @PathVariable FinanceRowType rowType) throws InstantiationException, IllegalAccessException { YourProjectCostsForm form = new YourProjectCostsForm(); form.setLabour(new LabourForm()); Map.Entry<Stri... | @Test public void ajaxAddRow() throws Exception { String rowId = "123"; LabourRowForm row = new LabourRowForm(); row.setCostId(Long.valueOf(rowId)); FinanceRowType type = FinanceRowType.LABOUR; doAnswer((invocation) -> { YourProjectCostsForm form = (YourProjectCostsForm) invocation.getArguments()[0]; form.getLabour().g... |
ApplicationUrlHelper { public static Optional<String> getQuestionUrl(QuestionSetupType questionType, long questionId, long applicationId) { if (questionType != null) { switch (questionType) { case APPLICATION_DETAILS: return Optional.of(format("/application/%d/form/question/%d/application-details", applicationId, quest... | @Test public void questionUrlForNoQuestionType() { QuestionSetupType questionSetupType = null; Optional<String> result = ApplicationUrlHelper.getQuestionUrl(questionSetupType, QUESTION_ID, APPLICATION_ID); assertEquals(Optional.empty(), result); }
@Test public void questionUrlForApplicationDetails() { QuestionSetupType... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override @Transactional public ServiceResult<QuestionResource> save(QuestionResource questionResource) { Question questionUpdated = questionRepository.save(questionMapper.mapToDomain(questionResource)); return serviceSuccess(questionMapp... | @Test public void saveQuestionResource() throws Exception { QuestionResource questionResource = newQuestionResource().build(); Question question = newQuestion().build(); when(questionMapperMock.mapToDomain(questionResource)).thenReturn(question); when(questionMapperMock.mapToResource(question)).thenReturn(questionResou... |
ApplicationInnovationAreaPopulator { public InnovationAreaViewModel populate(ApplicationResource applicationResource, Long questionId) { InnovationAreaViewModel innovationAreaViewModel = new InnovationAreaViewModel(); innovationAreaViewModel.setAvailableInnovationAreas(applicationInnovationAreaRestService.getAvailableI... | @Test public void populate() throws Exception { Long questionId = 1L; Long applicationId = 2L; String applicationName = "APP_NAME"; ApplicationResource applicationResource = newApplicationResource() .withId(applicationId) .withName(applicationName) .build(); when(applicationInnovationAreaRestService.getAvailableInnovat... |
ApplicationCreationAuthenticatedController { @GetMapping("/{competitionId}") public String view(Model model, @PathVariable(COMPETITION_ID) long competitionId, UserResource user, HttpServletResponse response) { Boolean userHasApplication = userService.userHasApplicationForCompetition(user.getId(), competitionId); if (Bo... | @Test public void getRequestWithExistingApplication() throws Exception { when(userService.userHasApplicationForCompetition(loggedInUser.getId(), 1L)).thenReturn(true); mockMvc.perform(get("/application/create-authenticated/{competitionId}", 1L)) .andExpect(status().is2xxSuccessful()) .andExpect(view().name("create-appl... |
ApplicationCreationAuthenticatedController { @PostMapping("/{competitionId}") public String post(@PathVariable(COMPETITION_ID) long competitionId, @Valid @ModelAttribute(FORM_NAME) ApplicationCreationAuthenticatedForm form, BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response) ... | @Test public void postEmptyFormShouldThrowError() throws Exception { when(competitionOrganisationConfigRestService.findByCompetitionId(1L)).thenReturn(RestResult.restSuccess(new CompetitionOrganisationConfigResource(false, false))); mockMvc.perform(post("/application/create-authenticated/1")) .andExpect(status().isOk()... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<QuestionResource> getQuestionByIdAndAssessmentId(Long questionId, Long assessmentId) { return find(getAssessment(assessmentId), getQuestionSupplier(questionId)).andOnSuccess((assessment, question) -> { if (q... | @Test public void getQuestionByIdAndAssessmentId() throws Exception { Long questionId = 1L; Long assessmentId = 2L; Competition competition = newCompetition() .build(); Application application = newApplication() .withCompetition(competition) .build(); Assessment assessment = newAssessment() .withApplication(application... |
ApplicationCreationController { @GetMapping("/start-application/{competitionId}") public String checkEligibility(Model model, @PathVariable(COMPETITION_ID) Long competitionId, HttpServletResponse response) { PublicContentItemResource publicContentItem = publicContentItemRestService.getItemByCompetitionId(competitionId)... | @Test public void checkEligibility() throws Exception { long competitionId = 1L; PublicContentItemResource publicContentItem = newPublicContentItemResource() .withCompetitionOpenDate(ZonedDateTime.now().minusDays(1)) .withCompetitionCloseDate(ZonedDateTime.now().plusDays(1)) .withNonIfs(false) .build(); when(publicCont... |
ReviewAndSubmitController { @SecuredBySpring(value = "APPLICANT_CONFIRM_SUBMIT", description = "Applicants can confirm they wish to submit their applications") @PreAuthorize("hasAuthority('applicant')") @GetMapping("/{applicationId}/confirm-submit") public String applicationConfirmSubmit(@PathVariable long applicationI... | @Test public void applicationConfirmSubmit() throws Exception { long applicationId = 2L; mockMvc.perform(get("/application/" + applicationId + "/confirm-submit") .flashAttr("termsAgreed", true)) .andExpect(view().name("application-confirm-submit")) .andExpect(model().attribute("applicationId", applicationId)); } |
ReviewAndSubmitController { @SecuredBySpring(value = "APPLICANT_CONFIRM_SUBMIT", description = "Applicants can confirm they wish to submit their applications") @PreAuthorize("hasAuthority('applicant')") @PostMapping("/{applicationId}/confirm-submit") public String applicationSubmit(Model model, @ModelAttribute(FORM_ATT... | @Test public void applicationSubmit() throws Exception { ApplicationResource application = newApplicationResource() .withCompetitionStatus(CompetitionStatus.OPEN) .withApplicationState(ApplicationState.OPENED) .build(); when(applicationRestService.getApplicationById(application.getId())).thenReturn(restSuccess(applicat... |
ReviewAndSubmitController { @SecuredBySpring(value = "APPLICANT_TRACK", description = "Applicants and kta can track their application after submitting.") @PreAuthorize("hasAnyAuthority('applicant', 'knowledge_transfer_adviser')") @GetMapping("/{applicationId}/track") public String applicationTrack(Model model, @PathVar... | @Test public void applicationTrack() throws Exception { CompetitionResource competition = newCompetitionResource() .build(); ApplicationResource application = newApplicationResource() .withApplicationState(SUBMITTED) .withCompetition(competition.getId()) .build(); when(applicationRestService.getApplicationById(applicat... |
OverheadFileSaver { public ValidationMessages handleOverheadFileRequest(HttpServletRequest request) { if(isOverheadFileUploadRequest(request)) { return uploadOverheadFile(request); } else if (isOverheadFileDeleteRequest(request)) { return deleteOverheadFile(request); } else { return new ValidationMessages(); } } Valid... | @Test public void uploadOverheadFileTestWrongInput() { StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest)setupUploadRequest(); when(request.getFileMap()).thenReturn(asMap("overheadfile", null)); when(request.getParameter("fileoverheadid")).thenReturn("ash!@#!@tasa"); ValidationMessages ... |
ApplicationOverviewViewModel implements BaseAnalyticsViewModel { public String getTermsAndConditionsTerminology() { if (FundingType.INVESTOR_PARTNERSHIPS == competition.getFundingType()) { return TERMS_AND_CONDITIONS_INVESTOR_PARTNERSHIPS; } return TERMS_AND_CONDITIONS_OTHER; } ApplicationOverviewViewModel(ProcessRoleR... | @Test public void termsAndConditionsTerminologyGivenInvestorPartnershipCompetition() { CompetitionResourceBuilder.newCompetitionResource().withFundingType(FundingType.INVESTOR_PARTNERSHIPS).build(); ApplicationOverviewViewModel viewModel = new ApplicationOverviewViewModel(null, CompetitionResourceBuilder.newCompetition... |
ApplicationOverviewController { @GetMapping("/{applicationId}") @AsyncMethod public String applicationOverview(Model model, @PathVariable("applicationId") long applicationId, UserResource user) { ApplicationResource application = applicationRestService.getApplicationById(applicationId) .getSuccess(); if (application.ge... | @Test public void applicationOverview() throws Exception { ApplicationResource application = newApplicationResource() .withCompetitionStatus(CompetitionStatus.OPEN) .withApplicationState(ApplicationState.CREATED) .build(); when(applicationRestService.getApplicationById(application.getId())).thenReturn(restSuccess(appli... |
ApplicationOverviewModelPopulator extends AsyncAdaptor { public ApplicationOverviewViewModel populateModel(ApplicationResource application, UserResource user) { Future<OrganisationResource> organisation = async(() -> organisationRestService.getByUserAndApplicationId(user.getId(), application.getId()).getSuccess()); Fut... | @Test public void populateModel() { CompetitionResource competition = newCompetitionResource() .withCollaborationLevel(SINGLE) .build(); ApplicationResource application = newApplicationResource() .withCompetition(competition.getId()) .build(); List<QuestionResource> questions = newQuestionResource() .withShortName("A q... |
LoginController { @GetMapping("/" + LOGIN_BASE + "/" + RESET_PASSWORD) public String requestPasswordReset(ResetPasswordRequestForm resetPasswordRequestForm, Model model) { model.addAttribute("resetPasswordRequestForm", resetPasswordRequestForm); return LOGIN_BASE + "/" + RESET_PASSWORD; } LoginController(UserService us... | @Test public void testRequestPasswordReset() throws Exception { mockMvc.perform(get("/" + LoginController.LOGIN_BASE + "/" + LoginController.RESET_PASSWORD)) .andExpect(status().isOk()) .andExpect(view().name(LoginController.LOGIN_BASE + "/" + LoginController.RESET_PASSWORD)); } |
LoginController { @PostMapping("/" + LOGIN_BASE + "/" + RESET_PASSWORD) public String requestPasswordResetPost(@ModelAttribute @Valid ResetPasswordRequestForm resetPasswordRequestForm, BindingResult bindingResult, Model model) { if (bindingResult.hasErrors()) { model.addAttribute("resetPasswordRequestForm", resetPasswo... | @Test public void testRequestPasswordResetPost() throws Exception { setLoggedInUser(null); String email = "test@test.nl"; when(userRestServiceMock.sendPasswordResetNotification(eq(email))).thenReturn(completedFuture(restSuccess())); mockMvc.perform( post("/" + LoginController.LOGIN_BASE + "/" + LoginController.RESET_PA... |
LoginController { @GetMapping("/" + LOGIN_BASE + "/" + RESET_PASSWORD + "/hash/{hash}") public String resetPassword(@PathVariable("hash") String hash, @ModelAttribute(binding = false) ResetPasswordForm resetPasswordForm, Model model, HttpServletRequest request) { userRestService.checkPasswordResetHash(hash).getSuccess(... | @Test public void testResetPassword() throws Exception { String hash = UUID.randomUUID().toString(); when(userRestServiceMock.checkPasswordResetHash(hash)).thenReturn(restSuccess()); mockMvc.perform(get("/" + LoginController.LOGIN_BASE + "/" + LoginController.RESET_PASSWORD + "/hash/" + hash)) .andExpect(status().isOk(... |
LoginController { @PostMapping("/" + LOGIN_BASE + "/" + RESET_PASSWORD + "/hash/{hash}") public String resetPasswordPost(@PathVariable("hash") String hash, @Valid @ModelAttribute ResetPasswordForm resetPasswordForm, BindingResult bindingResult) { userRestService.checkPasswordResetHash(hash).getSuccess(); if (bindingRes... | @Test public void testResetPasswordPost() throws Exception { String hash = UUID.randomUUID().toString(); String password = "Passw0rd12"; when(userRestServiceMock.checkPasswordResetHash(hash)).thenReturn(restSuccess()); when(userRestServiceMock.resetPassword(eq(hash), eq(password))).thenReturn(restSuccess()); mockMvc.pe... |
UserProfilePopulator { public UserProfileViewModel populate(UserResource user) { List<OrganisationResource> organisations = organisationRestService.getAllByUserId(user.getId()).getSuccess(); Set<OrganisationProfileViewModel> organisationViewModels = simpleMapSet(organisations, this::toOrganisationViewModel); String nam... | @Test public void populate() { UserResource user = newUserResource() .withFirstName("Steve") .withLastName("Smith") .withEmail("steve.smith@empire.com") .build(); List<OrganisationResource> organisations = newOrganisationResource() .withName("organisation") .withOrganisationTypeName("Type") .withCompaniesHouseNumber("1... |
ApplicantDashboardController { @SecuredBySpring(value = "ApplicantDashboardController", description = "applicant and kta has permission to view their own dashboard") @PreAuthorize("hasAnyAuthority('applicant', 'knowledge_transfer_adviser')") @GetMapping @NavigationRoot public String dashboard(Model model, UserResource ... | @Test public void dashboard() throws Exception { ApplicantDashboardViewModel viewModel = mock(ApplicantDashboardViewModel.class); when(populator.populate(loggedInUser.getId())).thenReturn(viewModel); mockMvc.perform(get("/applicant/dashboard")) .andExpect(status().isOk()) .andExpect(view().name("applicant-dashboard")) ... |
ApplicantDashboardController { @PostMapping(params = "hide-application") public String hideApplication(@RequestParam("hide-application") long applicationId, UserResource user) { applicationRestService.hideApplication(applicationId, user.getId()); return format("redirect:/applicant/dashboard"); } @SecuredBySpring(value... | @Test public void hideApplication() throws Exception { UserResource collaborator = this.collaborator; setLoggedInUser(collaborator); long applicationId = 1L; long userId = 1L; when(applicationRestService.hideApplication(applicationId, userId)).thenReturn(RestResult.restSuccess()); mockMvc.perform(post("/applicant/dashb... |
ApplicantDashboardController { @PostMapping(params = "delete-application") public String deleteApplication(@RequestParam("delete-application") long applicationId) { applicationRestService.deleteApplication(applicationId); return format("redirect:/applicant/dashboard"); } @SecuredBySpring(value = "ApplicantDashboardCon... | @Test public void deleteApplication() throws Exception { setLoggedInUser(applicant); long applicationId = 1L; when(applicationRestService.deleteApplication(applicationId)).thenReturn(RestResult.restSuccess()); mockMvc.perform(post("/applicant/dashboard").param("delete-application", valueOf(applicationId))) .andExpect(s... |
ApplicantDashboardPopulator { public ApplicantDashboardViewModel populate(Long userId) { ApplicantDashboardResource applicantDashboardResource = applicantRestService.getApplicantDashboard(userId); return getApplicantDashboardViewModel(applicantDashboardResource); } ApplicantDashboardViewModel populate(Long userId); } | @Test public void testPopulateInSetupProjects() { DashboardInSetupRowResource inSetup = aDashboardInSetupRowResource() .withCompetitionTitle("Competition Title") .withProjectId(3L) .withProjectTitle("Project Title") .build(); List<DashboardInSetupRowResource> inSetUp = singletonList(inSetup); setupDashboard(inSetUp, em... |
SiteTermsController { @PreAuthorize("permitAll") @GetMapping("terms-and-conditions") public String termsAndConditions() { SiteTermsAndConditionsResource siteTermsAndConditions = termsAndConditionsRestService .getLatestSiteTermsAndConditions().getSuccess(); return format("content/%s", siteTermsAndConditions.getTemplate(... | @Test public void termsAndConditions() throws Exception { SiteTermsAndConditionsResource siteTermsAndConditionsResource = newSiteTermsAndConditionsResource() .withTemplate("test-terms-and-conditions") .build(); when(termsAndConditionsRestService.getLatestSiteTermsAndConditions()).thenReturn( restSuccess(siteTermsAndCon... |
SiteTermsController { @GetMapping("new-terms-and-conditions") public String newTermsAndConditions(@ModelAttribute(name = "form") NewSiteTermsAndConditionsForm form) { return "content/new-terms-and-conditions"; } @PreAuthorize("permitAll") @GetMapping("terms-and-conditions") String termsAndConditions(); @GetMapping("ne... | @Test public void newTermsAndConditions() throws Exception { NewSiteTermsAndConditionsForm expectedForm = new NewSiteTermsAndConditionsForm(); mockMvc.perform(get("/info/new-terms-and-conditions")) .andExpect(status().isOk()) .andExpect(model().attribute("form", expectedForm)) .andExpect(view().name("content/new-terms-... |
SiteTermsController { @PostMapping("new-terms-and-conditions") public String agreeNewTermsAndConditions(HttpServletRequest request, HttpServletResponse response, UserResource loggedInUser, @Valid @ModelAttribute(name = "form") NewSiteTermsAndConditionsForm form, @SuppressWarnings("unused") BindingResult bindingResult, ... | @Test public void agreeNewTermsAndConditions() throws Exception { long userId = 1L; String expectedRedirectUrl = "/application/99/summary"; when(userRestService.agreeNewSiteTermsAndConditions(userId)).thenReturn(restSuccess()); when(cookieUtil.getCookieValue(isA(HttpServletRequest.class), eq("savedRequestUrl"))) .thenR... |
StaticContentController { @GetMapping("contact") public String contact() { return "content/contact"; } @GetMapping("contact") String contact(); @GetMapping("cookies") String cookies(); @GetMapping("accessibility") String accessibility(); } | @Test public void contact() throws Exception { mockMvc.perform(get("/info/contact")) .andExpect(status().isOk()) .andExpect(view().name("content/contact")); } |
StaticContentController { @GetMapping("cookies") public String cookies() { return "content/cookies"; } @GetMapping("contact") String contact(); @GetMapping("cookies") String cookies(); @GetMapping("accessibility") String accessibility(); } | @Test public void cookies() throws Exception { mockMvc.perform(get("/info/cookies")) .andExpect(status().isOk()) .andExpect(view().name("content/cookies")); } |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<List<QuestionResource>> getQuestionsByAssessmentId(Long assessmentId) { return find(getAssessment(assessmentId)).andOnSuccess(assessment -> sectionService.getByCompetitionIdVisibleForAssessment( applicationR... | @Test public void getQuestionsByAssessmentId() { Long assessmentId = 1L; Long competitionId = 2L; Competition competition = newCompetition() .with(id(competitionId)) .build(); Application application = newApplication() .withCompetition(competition) .build(); ProcessRole processRole = newProcessRole() .withApplication(a... |
StaticContentController { @GetMapping("accessibility") public String accessibility() { return "content/accessibility"; } @GetMapping("contact") String contact(); @GetMapping("cookies") String cookies(); @GetMapping("accessibility") String accessibility(); } | @Test public void accessibility() throws Exception { mockMvc.perform(get("/info/accessibility")) .andExpect(status().isOk()) .andExpect(view().name("content/accessibility")); } |
ExternalUserRegistrationController { @GetMapping("/{inviteHash}/register") public String yourDetails(Model model, @PathVariable("inviteHash") String inviteHash, @ModelAttribute(name = FORM_ATTR_NAME, binding = false) RegistrationForm form, UserResource loggedInUser) { RoleInviteResource invite = inviteUserRestService.g... | @Test public void testYourDetails() throws Exception { setLoggedInUser(null); when(inviteUserRestService.getInvite("hash")).thenReturn(restSuccess(newRoleInviteResource() .withRole(Role.KNOWLEDGE_TRANSFER_ADVISER) .withEmail("blah@gmail.com") .build())); MvcResult result = mockMvc.perform(get(URL_PREFIX + "/hash/regist... |
ExternalUserRegistrationController { @PostMapping("/{inviteHash}/register") public String submitYourDetails(Model model, @PathVariable("inviteHash") String inviteHash, @Validated({Default.class, PhoneNumberValidationGroup.class, TermsValidationGroup.class}) @ModelAttribute("form") RegistrationForm registrationForm, Bin... | @Test public void testSubmitYourDetails() throws Exception { setLoggedInUser(null); when(inviteUserRestService.getInvite("hash")).thenReturn(restSuccess(newRoleInviteResource() .withRole(Role.KNOWLEDGE_TRANSFER_ADVISER) .withEmail("blah@gmail.com") .build())); RegistrationForm registrationForm = new RegistrationForm();... |
ExternalUserRegistrationController { @GetMapping(value = "/{inviteHash}/register/account-created") public String accountCreated(@PathVariable("inviteHash") String inviteHash, UserResource loggedInUser) { boolean userIsLoggedIn = loggedInUser != null; if (userIsLoggedIn) { return "redirect:/"; } return inviteUserRestSer... | @Test public void testAccountCreated() throws Exception { setLoggedInUser(null); when(inviteUserRestService.checkExistingUser("hash")).thenReturn(RestResult.restSuccess(true)); mockMvc.perform(get(URL_PREFIX + "/hash/register/account-created")) .andExpect(status().isOk()) .andExpect(view().name("registration/external-a... |
RegistrationController { private ServiceResult<UserResource> createUser(RegistrationForm registrationForm, Long organisationId, Long competitionId) { return userRestService.createUser( registrationForm.constructUserCreationResource() .withOrganisationId(organisationId) .withCompetitionId(competitionId) .withRole(Role.A... | @Test public void tooWeakPasswordSizeShouldReturnError() throws Exception { logoutCurrentUser(); OrganisationResource organisation = newOrganisationResource().withId(1L).withName("Organisation 1").build(); when(organisationRestService.getOrganisationByIdForAnonymousUserFlow(1L)).thenReturn(restSuccess(organisation)); S... |
RegistrationController { @GetMapping("/resend-email-verification") public String resendEmailVerification(final ResendEmailVerificationForm resendEmailVerificationForm, final Model model) { model.addAttribute("resendEmailVerificationForm", resendEmailVerificationForm); return "registration/resend-email-verification"; } ... | @Test public void resendEmailVerification() throws Exception { mockMvc.perform(get("/registration/resend-email-verification")) .andExpect(status().isOk()) .andExpect(view().name("registration/resend-email-verification")); } |
AcceptApplicationKtaInviteController extends AbstractAcceptInviteController { @GetMapping("/kta/accept-invite/{hash}") @SecuredBySpring(value = "READ", description = "All users can view the invite to join an application.") @PreAuthorize("permitAll") public String inviteEntryPage( @PathVariable("hash") final String hash... | @Test public void inviteEntryPage() throws Exception { String email = "user@ktn-uk.org"; String hash = "hash123"; UserResource ktaUser = newUserResource().withRoleGlobal(KNOWLEDGE_TRANSFER_ADVISER).withEmail(email).build(); ApplicationKtaInviteResource applicationKtaInviteResource = newApplicationKtaInviteResource().wi... |
AcceptApplicationKtaInviteController extends AbstractAcceptInviteController { @GetMapping("/kta/accept-invite/{hash}/accept") @PreAuthorize("hasAuthority('knowledge_transfer_adviser')") @SecuredBySpring(value = "ACCEPT", description = "KTA users can accept invite to join an application.") public String acceptKtaPage( @... | @Test public void acceptKtaPage() throws Exception { String email = "ktaUser@ktn-uk.org"; String hash = "hash123"; UserResource ktaUser = newUserResource().withRoleGlobal(KNOWLEDGE_TRANSFER_ADVISER).withEmail(email).build(); ApplicationKtaInviteResource applicationKtaInviteResource = newApplicationKtaInviteResource().w... |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<Question> getQuestionByCompetitionIdAndFormInputType(Long competitionId, FormInputType formInputType) { List<FormInput> formInputs = formInputRepository.findByCompetitionIdAndTypeIn(competitionId, singletonL... | @Test public void testGetQuestionByCompetitionIdAndFormInputTypeSuccess() { long competitionId = 1L; Question question = newQuestion().build(); FormInput formInput = newFormInput(). withType(FormInputType.TEXTAREA). withQuestion(question). build(); when(formInputRepositoryMock.findByCompetitionIdAndTypeIn(competitionId... |
AcceptRejectApplicationKtaInviteModelPopulator { public AcceptRejectApplicationKtaInviteViewModel populateModel(ApplicationKtaInviteResource invite) { return new AcceptRejectApplicationKtaInviteViewModel(invite.getApplication(), invite.getApplicationName(), invite.getCompetitionName(), invite.getLeadOrganisationName(),... | @Test public void populateModel() { long applicationId= 123L; ApplicationKtaInviteResource invite = newApplicationKtaInviteResource() .withApplication(applicationId) .withApplicationName("KTP Application") .withCompetitionName("KTP Competition") .withLeadApplicant("Steve Smith") .withLeadOrganisationName("Empire Ltd") ... |
AssessmentSummaryController { @GetMapping("/{assessmentId}/summary") public String getSummary(Model model, @ModelAttribute(name = FORM_ATTR_NAME, binding = false) AssessmentSummaryForm form, BindingResult bindingResult, @PathVariable("assessmentId") long assessmentId) { AssessmentResource assessment = assessmentService... | @Test public void getSummary() throws Exception { long applicationId = 1L; CompetitionResource competitionResource = setupCompetitionResource(); AssessmentResource assessmentResource = setupAssessment(applicationId, competitionResource.getId()); List<QuestionResource> questionResources = setupQuestions(competitionResou... |
AssessmentSummaryController { @PostMapping("/{assessmentId}/summary") public String save(Model model, @Valid @ModelAttribute(FORM_ATTR_NAME) AssessmentSummaryForm form, BindingResult bindingResult, ValidationHandler validationHandler, @PathVariable("assessmentId") Long assessmentId) { Supplier<String> failureView = () ... | @Test public void save() throws Exception { CompetitionResource competitionResource = setupCompetitionResource(); AssessmentResource assessmentResource = newAssessmentResource() .withCompetition(competitionResource.getId()) .build(); String feedback = String.join(" ", nCopies(100, "feedback")); String comment = String.... |
UpcomingCompetitionViewModel { public boolean isKtpCompetition() { return ktpCompetition; } UpcomingCompetitionViewModel(CompetitionResource competitionResource, CompetitionAssessmentConfigResource competitionAssessmentConfigResource); long getCompetitionId(); String getCompetitionName(); void setCompetitionName(String... | @Test public void testNonKtpCompetition() { CompetitionResource competitionResource = CompetitionResourceBuilder.newCompetitionResource() .withFundingType(FundingType.GRANT) .build(); CompetitionAssessmentConfigResource competitionAssessmentConfigResource = CompetitionAssessmentConfigResourceBuilder .newCompetitionAsse... |
AssessorProfileStatusViewModel { public boolean isSkillsComplete() { return skillsComplete; } AssessorProfileStatusViewModel(UserProfileStatusResource userProfileStatusResource, RoleProfileState roleProfileState); boolean isSkillsComplete(); boolean isAffiliationsComplete(); boolean isAgreementComplete(); boolean isCom... | @Test public void isSkillsComplete() { assertFalse(nothingCompleteProfileStatus.isSkillsComplete()); assertTrue(skillsCompleteProfileStatus.isSkillsComplete()); assertFalse(affiliationsCompleteProfileStatus.isSkillsComplete()); assertFalse(agreementCompleteProfileStatus.isSkillsComplete()); assertTrue(allCompleteProfil... |
AssessorProfileStatusViewModel { public boolean isAffiliationsComplete() { return affiliationsComplete; } AssessorProfileStatusViewModel(UserProfileStatusResource userProfileStatusResource, RoleProfileState roleProfileState); boolean isSkillsComplete(); boolean isAffiliationsComplete(); boolean isAgreementComplete(); b... | @Test public void isAffiliationsComplete() { assertFalse(nothingCompleteProfileStatus.isAffiliationsComplete()); assertFalse(skillsCompleteProfileStatus.isAffiliationsComplete()); assertTrue(affiliationsCompleteProfileStatus.isAffiliationsComplete()); assertFalse(agreementCompleteProfileStatus.isAffiliationsComplete())... |
AssessorProfileStatusViewModel { public boolean isAgreementComplete() { return agreementComplete; } AssessorProfileStatusViewModel(UserProfileStatusResource userProfileStatusResource, RoleProfileState roleProfileState); boolean isSkillsComplete(); boolean isAffiliationsComplete(); boolean isAgreementComplete(); boolean... | @Test public void isAgreementComplete() { assertFalse(nothingCompleteProfileStatus.isAgreementComplete()); assertFalse(skillsCompleteProfileStatus.isAgreementComplete()); assertFalse(affiliationsCompleteProfileStatus.isAgreementComplete()); assertTrue(agreementCompleteProfileStatus.isAgreementComplete()); assertTrue(al... |
AssessorProfileStatusViewModel { public boolean isComplete() { return skillsComplete && affiliationsComplete && agreementComplete; } AssessorProfileStatusViewModel(UserProfileStatusResource userProfileStatusResource, RoleProfileState roleProfileState); boolean isSkillsComplete(); boolean isAffiliationsComplete(); boole... | @Test public void isComplete() { assertFalse(nothingCompleteProfileStatus.isComplete()); assertFalse(skillsCompleteProfileStatus.isComplete()); assertFalse(affiliationsCompleteProfileStatus.isComplete()); assertFalse(agreementCompleteProfileStatus.isComplete()); assertTrue(allCompleteProfileStatus.isComplete()); } |
AssessorProfileTravelController { @GetMapping public String getTravelAndSubsistence() { return "profile/travel"; } @GetMapping String getTravelAndSubsistence(); } | @Test public void getTravelAndSubsistence() throws Exception { mockMvc.perform(get("/profile/travel")) .andExpect(status().isOk()) .andExpect(view().name("profile/travel")); } |
QuestionServiceImpl extends BaseTransactionalService implements QuestionService { @Override public ServiceResult<QuestionResource> getQuestionByCompetitionIdAndQuestionSetupType(final long competitionId, final QuestionSetupType questionSetupType) { return find(questionRepository.findFirstByCompetitionIdAndQuestionSetup... | @Test public void getQuestionByCompetitionIdAndQuestionSetupType() { long competitionId = 1L; Question question = newQuestion().build(); QuestionResource questionResource = newQuestionResource() .build(); when(questionRepositoryMock.findFirstByCompetitionIdAndQuestionSetupType(competitionId, APPLICATION_DETAILS)).thenR... |
AssessorProfileSkillsEditController { @GetMapping("/edit") public String getSkills(Model model, UserResource loggedInUser, @ModelAttribute(name = FORM_ATTR_NAME, binding = false) AssessorProfileSkillsForm form, BindingResult bindingResult) { return doViewEditSkills(model, loggedInUser, form, bindingResult); } @GetMapp... | @Test public void getSkills() throws Exception { BusinessType businessType = BUSINESS; String skillAreas = "skill1 skill2 skill3"; List<InnovationAreaResource> innovationAreaResources = setUpInnovationAreasForSector("Emerging and enabling", "Data", "Cyber Security"); UserResource userResource = setUpProfileSkills(busin... |
AssessorProfileSkillsEditController { @PostMapping("/edit") public String submitSkills(Model model, UserResource loggedInUser, @Valid @ModelAttribute(FORM_ATTR_NAME) AssessorProfileSkillsForm form, BindingResult bindingResult, ValidationHandler validationHandler) { Supplier<String> failureView = () -> doViewEditSkills(... | @Test public void submitSkills() throws Exception { BusinessType businessType = BUSINESS; String skillAreas = String.join(" ", nCopies(100, "skill")); ProfileSkillsEditResource profileSkillsEditResource = newProfileSkillsEditResource() .withBusinessType(businessType) .withSkillsAreas(skillAreas) .build(); when(profileR... |
AssessorProfileDeclarationEditController { @GetMapping(path = "/edit") public String getEditDeclaration(UserResource loggedInUser, @ModelAttribute(name = FORM_ATTR_NAME, binding = false) AssessorProfileDeclarationForm form, BindingResult bindingResult) { if (!bindingResult.hasErrors()) { assessorProfileDeclarationFormP... | @Test public void getEditDeclaration() throws Exception { UserResource user = newUserResource().build(); setLoggedInUser(user); String expectedPrincipalEmployer = "Big Name Corporation"; String expectedRole = "Financial Accountant"; String expectedProfessionalAffiliations = "Professional affiliations..."; List<Assessor... |
AssessorProfileDeclarationEditController { @PostMapping(path = "/edit") public String submitDeclaration(UserResource loggedInUser, @Valid @ModelAttribute(FORM_ATTR_NAME) AssessorProfileDeclarationForm form, BindingResult bindingResult, ValidationHandler validationHandler) { Supplier<String> failureView = () -> getEditD... | @Test public void submitDeclaration() throws Exception { UserResource user = newUserResource().build(); setLoggedInUser(user); String principalEmployer = "Big Name Corporation"; String role = "Financial Accountant"; String professionalAffiliations = "Professional affiliations..."; String hasAppointments = "true"; List<... |
AssessorProfileDeclarationEditController { @PostMapping(path = "/edit", params = {"addAppointment"}) public String addAppointment(@ModelAttribute(FORM_ATTR_NAME) AssessorProfileDeclarationForm form) { form.getAppointments().add(new AssessorProfileAppointmentForm()); return doEditDeclaration(); } @GetMapping String get... | @Test public void addAppointment() throws Exception { UserResource user = newUserResource().build(); setLoggedInUser(user); String principalEmployer = "Big Name Corporation"; String role = "Financial Accountant"; String professionalAffiliations = "Professional affiliations..."; String hasAppointments = "true"; String h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.