src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
AdditionalCompanyCostCategory implements FinanceRowCostCategory { @Override public void addCost(FinanceRowItem costItem) { AdditionalCompanyCost cost = (AdditionalCompanyCost) costItem; switch (cost.getType()) { case ASSOCIATE_SALARY: associateSalary = cost; break; case MANAGEMENT_SUPERVISION: managementSupervision = c... | @Test public void addCost() { AdditionalCompanyCost newConsumables = newAdditionalCompanyCost() .withType(AdditionalCompanyCost.AdditionalCompanyCostType.CONSUMABLES) .withDescription("newAdditionalCompanyCost") .withCost(BigInteger.valueOf(700)) .build(); BigDecimal newResult = associateSalary.getTotal() .add(manageme... |
AdditionalCompanyCostCategory implements FinanceRowCostCategory { @Override public boolean excludeFromTotalCost() { return true; } AdditionalCompanyCost getAssociateSalary(); void setAssociateSalary(AdditionalCompanyCost associateSalary); AdditionalCompanyCost getManagementSupervision(); void setManagementSupervision(... | @Test public void checkCostCategoryNotToSetToExcludeFromTotalCosts() { assertTrue(additionalCompanyCostCategory.excludeFromTotalCost()); } |
LabourCostCategory implements FinanceRowCostCategory { @Override public List<FinanceRowItem> getCosts() { return costs; } @Override List<FinanceRowItem> getCosts(); void setCosts(List<FinanceRowItem> costItems); @Override BigDecimal getTotal(); @Override void calculateTotal(); Integer getWorkingDaysPerYear(); LabourCo... | @Test public void getCosts() { assertEquals(costs, labourCostCategory.getCosts()); } |
LabourCostCategory implements FinanceRowCostCategory { public Integer getWorkingDaysPerYear() { if (workingDaysPerYearCostItem != null) { return workingDaysPerYearCostItem.getLabourDays(); } else { return 0; } } @Override List<FinanceRowItem> getCosts(); void setCosts(List<FinanceRowItem> costItems); @Override BigDeci... | @Test public void getWorkingDaysPerYear() { Integer result = workingDays.getLabourDays(); assertEquals(result, labourCostCategory.getWorkingDaysPerYear()); }
@Test public void getWorkingDaysPerYearWithNullWorkingDays() { Integer result = 0; workingDays.setLabourDays(0); assertEquals(result, labourCostCategory.getWorkin... |
LabourCostCategory implements FinanceRowCostCategory { public LabourCost getWorkingDaysPerYearCostItem() { return workingDaysPerYearCostItem; } @Override List<FinanceRowItem> getCosts(); void setCosts(List<FinanceRowItem> costItems); @Override BigDecimal getTotal(); @Override void calculateTotal(); Integer getWorkingD... | @Test public void getWorkingDaysPerYearCostItem() { assertEquals(workingDays, labourCostCategory.getWorkingDaysPerYearCostItem()); } |
LabourCostCategory implements FinanceRowCostCategory { @Override public void addCost(FinanceRowItem costItem) { if (costItem != null) { LabourCost labourCost = (LabourCost) costItem; if (WORKING_DAYS_PER_YEAR.equals(labourCost.getDescription())) { workingDaysPerYearCostItem = (LabourCost) costItem; } else { costs.add(c... | @Test public void addCost() { LabourCost testerCost = newLabourCost() .withLabourDays(100) .withGrossEmployeeCost(BigDecimal.valueOf(10000)) .withRole("Tester") .build(); costs.add(testerCost); labourCostCategory.addCost(testerCost); assertEquals(costs, labourCostCategory.getCosts()); } |
LabourCostCategory implements FinanceRowCostCategory { @Override public boolean excludeFromTotalCost() { return false; } @Override List<FinanceRowItem> getCosts(); void setCosts(List<FinanceRowItem> costItems); @Override BigDecimal getTotal(); @Override void calculateTotal(); Integer getWorkingDaysPerYear(); LabourCos... | @Test public void checkCostCategorySetToExcludeFromTotalCosts() { assertFalse(labourCostCategory.excludeFromTotalCost()); } |
ExcludedCostCategory extends DefaultCostCategory { @Override public BigDecimal getTotal() { return BigDecimal.ZERO; } @Override boolean excludeFromTotalCost(); @Override BigDecimal getTotal(); } | @Test public void getTotal() { grantClaimCategory.calculateTotal(); assertEquals(BigDecimal.ZERO, grantClaimCategory.getTotal()); } |
ExcludedCostCategory extends DefaultCostCategory { @Override public boolean excludeFromTotalCost() { return true; } @Override boolean excludeFromTotalCost(); @Override BigDecimal getTotal(); } | @Test public void checkCostCategorySetToExcludeFromTotalCosts() { assertTrue(grantClaimCategory.excludeFromTotalCost()); } |
DefaultCostCategory implements FinanceRowCostCategory { @Override public List<FinanceRowItem> getCosts() { return costs; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCost... | @Test public void getCosts() { assertEquals(costs, defaultCostCategory.getCosts()); } |
DefaultCostCategory implements FinanceRowCostCategory { @Override public BigDecimal getTotal() { return total; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCost(); void s... | @Test public void getTotal() { defaultCostCategory.calculateTotal(); assertEquals(new BigDecimal(3000), defaultCostCategory.getTotal()); } |
DefaultCostCategory implements FinanceRowCostCategory { @Override public void addCost(FinanceRowItem costItem) { if(costItem!=null) { costs.add(costItem); } } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @O... | @Test public void addCost() { FinanceRowItem cost3 = newMaterials() .withCost(new BigDecimal(1000)) .withQuantity(1) .build(); costs.add(cost3); defaultCostCategory.addCost(cost3); assertEquals(costs, defaultCostCategory.getCosts()); } |
DefaultCostCategory implements FinanceRowCostCategory { @Override public boolean excludeFromTotalCost() { return false; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCost(... | @Test public void checkCostCategorySetToExcludeFromTotalCosts() { assertFalse(defaultCostCategory.excludeFromTotalCost()); } |
OverheadCostCategory implements FinanceRowCostCategory { @Override public List<FinanceRowItem> getCosts() { return costs; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCos... | @Test public void getCosts() { assertEquals(costs, overheadCostCategory.getCosts()); } |
OverheadCostCategory implements FinanceRowCostCategory { @Override public BigDecimal getTotal() { return total; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCost(); void ... | @Test public void getTotal() { BigDecimal labourCostTotal = new BigDecimal(1000); overheadCostCategory.setLabourCostTotal(labourCostTotal); overheadCostCategory.calculateTotal(); assertEquals(200, overheadCostCategory.getTotal().intValue()); } |
OrganisationPermissionRules { @PermissionRule(value = "READ", description = "The System Registration User can search for Organisations on behalf of non-logged in " + "users during the registration process") public boolean systemRegistrationUserCanSeeOrganisationSearchResults(OrganisationSearchResult organisation, UserR... | @Test public void systemRegistrationUserCanSeeOrganisationSearchResults() { allGlobalRoleUsers.forEach(user -> { if (user.equals(systemRegistrationUser())) { assertTrue(rules.systemRegistrationUserCanSeeOrganisationSearchResults(new OrganisationSearchResult(), user)); } else { assertFalse(rules.systemRegistrationUserCa... |
OverheadCostCategory implements FinanceRowCostCategory { @Override public void addCost(FinanceRowItem costItem) { if(costItem!=null) { costs.add(costItem); } } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @... | @Test public void addCost() { FinanceRowItem overHead2 = newOverhead().withRate(20).build(); costs.add(overHead2); overheadCostCategory.addCost(overHead2); assertEquals(costs, overheadCostCategory.getCosts()); } |
OverheadCostCategory implements FinanceRowCostCategory { @Override public boolean excludeFromTotalCost() { return false; } @Override List<FinanceRowItem> getCosts(); @Override BigDecimal getTotal(); @Override void calculateTotal(); @Override void addCost(FinanceRowItem costItem); @Override boolean excludeFromTotalCost... | @Test public void checkCostCategorySetToExcludeFromTotalCosts() { assertFalse(overheadCostCategory.excludeFromTotalCost()); } |
CapitalUsage extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { if (npv == null || residualValue == null || utilisation == null) { return BigDecimal.ZERO; } return npv.subtract(residualValue) .multiply(new BigDecimal(utilisation) .divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_EVEN)); } pri... | @Test public void getTotal() { assertEquals(BigDecimal.valueOf(1250).setScale(2, BigDecimal.ROUND_HALF_EVEN), capitalUsage.getTotal()); }
@Test public void totalMustBeZeroWhenDataIsNotAvailableTest() { CapitalUsage emptyCapitalUsage = new CapitalUsage(1L); assertEquals(BigDecimal.ZERO, emptyCapitalUsage.getTotal()); } |
CapitalUsage extends AbstractFinanceRowItem { @Override public String getName() { return getCostType().getType(); } private CapitalUsage(); CapitalUsage(Long targetId); CapitalUsage(Long id, Integer deprecation, String description, String existing,
BigDecimal npv, BigDecimal residualValue, In... | @Test public void getName() { assertEquals("capital_usage", capitalUsage.getName()); } |
CapitalUsage extends AbstractFinanceRowItem { @Override public boolean isEmpty() { return false; } private CapitalUsage(); CapitalUsage(Long targetId); CapitalUsage(Long id, Integer deprecation, String description, String existing,
BigDecimal npv, BigDecimal residualValue, Integer utilisation... | @Test public void isEmpty() { assertFalse(capitalUsage.isEmpty()); } |
CapitalUsage extends AbstractFinanceRowItem { @Override public FinanceRowType getCostType() { return FinanceRowType.CAPITAL_USAGE; } private CapitalUsage(); CapitalUsage(Long targetId); CapitalUsage(Long id, Integer deprecation, String description, String existing,
BigDecimal npv, BigDecimal ... | @Test public void getCostType() { assertEquals(CAPITAL_USAGE, capitalUsage.getCostType()); } |
ProcurementOverhead extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { BigDecimal total = BigDecimal.ZERO; if (companyCost != null && projectCost != null) { total = projectCost.multiply(new BigDecimal(companyCost).divide(ONE_HUNDRED)); } return total; } ProcurementOverhead(); ProcurementOverhead... | @Test public void totalForOverhead_NullProjectCost() { companyCost = 100; projectCost = null; overhead = new ProcurementOverhead(id, item, projectCost, companyCost, target_id); assertEquals(BigDecimal.ZERO, overhead.getTotal()); }
@Test public void totalForOverhead_NullCompanyCost() { companyCost = null; projectCost = ... |
OrganisationPermissionRules { @PermissionRule(value = "READ", description = "Project Partners can see the Partner Organisations within their Projects") public boolean projectPartnerUserCanSeePartnerOrganisationsWithinTheirProjects(OrganisationResource organisation, UserResource user) { List<ProjectUser> projectRoles = ... | @Test public void projectPartnerUserCanSeePartnerOrganisationsWithinTheirProjects() { UserResource user = newUserResource().build(); Organisation differentOrganisation = newOrganisation().build(); Organisation organisationBeingChecked = newOrganisation().build(); Organisation anotherDifferentOrganisation = newOrganisat... |
LabourCost extends AbstractFinanceRowItem { public BigDecimal getRate(Integer workingDaysPerYear) { rate = getRatePerDay(workingDaysPerYear); return rate; } private LabourCost(); LabourCost(Long targetId); LabourCost(Long id, String name, String role, BigDecimal grossEmployeeCost, Integer labourDays, String descript... | @Test public void getRate() { Integer workingDaysPerYear = 232; BigDecimal ratePerDay = labourCost.getRate(workingDaysPerYear); BigDecimal expected = new BigDecimal(215.51724).setScale(5, BigDecimal.ROUND_HALF_EVEN); assertEquals(expected, ratePerDay); }
@Test public void rateNullLabourDays() { Integer workingDaysPerYe... |
LabourCost extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { return total; } private LabourCost(); LabourCost(Long targetId); LabourCost(Long id, String name, String role, BigDecimal grossEmployeeCost, Integer labourDays, String description, Long targetId); @Override Long getId(); @Override S... | @Test public void getLabourCostTotal() { Integer workingDaysPerYear = 232; BigDecimal totalLabourCost = labourCost.getTotal(workingDaysPerYear); BigDecimal expected = new BigDecimal(36206.89632).setScale(5, BigDecimal.ROUND_HALF_EVEN); BigDecimal totalStoredLabourCost = labourCost.getTotal(); assertEquals(expected, tot... |
Overhead extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { return BigDecimal.ZERO; } private Overhead(); Overhead(Long targetId); Overhead(Long id, OverheadRateType rateType, Integer rate, Long targetId); Integer getRate(); @Override BigDecimal getTotal(); @Override Long getId(); @Override Fi... | @Test public void totalForOverheadShouldAlwaysBeZeroTest() throws Exception { assertEquals(BigDecimal.ZERO, overhead.getTotal()); } |
SubContractingCost extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { return cost; } private SubContractingCost(); SubContractingCost(Long targetId); SubContractingCost(Long id, BigDecimal cost, String country, String name, String role, Long targetId); @Override Long getId(); BigDecimal getCos... | @Test public void calculateTotalsForSubContractingTest() throws Exception { BigDecimal expected = new BigDecimal(10023); assertEquals(expected, subContractingCost.getTotal()); } |
TravelCost extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { if (cost == null || quantity == null) { return BigDecimal.ZERO; } return cost.multiply(new BigDecimal(quantity)); } private TravelCost(); TravelCost(Long targetId); TravelCost(Long id, String item, BigDecimal cost, Integer quantity,... | @Test public void calculateTotalsForTravelCostTest() throws Exception { BigDecimal expected = new BigDecimal(600).multiply(new BigDecimal(12)); assertEquals(expected, travelCost.getTotal()); }
@Test public void calculatedTotalMustBeZeroWhenQuantityOrCostAreNotSetTest() throws Exception { TravelCost travelCostWithoutVal... |
OtherCost extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { return cost; } private OtherCost(); OtherCost(Long targetId); OtherCost(Long id, String description, BigDecimal cost, Long targetId); @Override Long getId(); BigDecimal getCost(); String getDescription(); @Override BigDecimal getTota... | @Test public void calculateTotalsForOtherCostTest() throws Exception { BigDecimal expected = new BigDecimal(1000); assertEquals(expected, otherCost.getTotal()); } |
Materials extends AbstractFinanceRowItem { @Override public BigDecimal getTotal() { BigDecimal total = BigDecimal.ZERO; if (quantity != null && cost != null) { total = cost.multiply(new BigDecimal(quantity)); } return total; } private Materials(); Materials(Long targetId); Materials(Long id, String item, BigDecimal ... | @Test public void calculateTotalsForMaterialsTest() throws Exception { BigDecimal expected = new BigDecimal(2000).multiply(new BigDecimal(12)); assertEquals(expected, materials.getTotal()); }
@Test public void calculatedTotalMustBeZeroWhenQuantityOrCostAreNotSetTest() throws Exception { Materials materialWithoutValues ... |
ResearchCategoryResource extends CategoryResource { @Override public CategoryType getType() { return RESEARCH_CATEGORY; } @Override CategoryType getType(); } | @Test public void getType() throws Exception { assertEquals(newResearchCategoryResource().build().getType(), RESEARCH_CATEGORY); } |
InnovationSectorResource extends CategoryResource { @Override public CategoryType getType() { return CategoryType.INNOVATION_SECTOR; } List<InnovationAreaResource> getChildren(); void setChildren(List<InnovationAreaResource> children); @Override CategoryType getType(); @Override boolean equals(Object o); @Override int... | @Test public void getType() throws Exception { assertEquals(newInnovationSectorResource().build().getType(), INNOVATION_SECTOR); } |
InnovationAreaResource extends CategoryResource { @Override public CategoryType getType() { return INNOVATION_AREA; } @Override CategoryType getType(); Long getSector(); void setSector(Long sector); String getSectorName(); void setSectorName(String sectorName); @JsonIgnore boolean isNone(); @JsonIgnore boolean isNotNo... | @Test public void getType() { assertEquals(newInnovationAreaResource().build().getType(), INNOVATION_AREA); } |
InnovationAreaResource extends CategoryResource { @JsonIgnore public boolean isNotNone() { return !isNone(); } @Override CategoryType getType(); Long getSector(); void setSector(Long sector); String getSectorName(); void setSectorName(String sectorName); @JsonIgnore boolean isNone(); @JsonIgnore boolean isNotNone(); @... | @Test public void isNotNone() { assertTrue(newInnovationAreaResource().withName("Foo").build().isNotNone()); assertFalse(newInnovationAreaResource().withName("None").build().isNotNone()); } |
FinanceCheckSummaryResource { public boolean isAllEligibilityAndViabilityInReview() { return partnerStatusResources .stream() .allMatch(partner -> partner.getViability().isInReviewOrNotApplicable() && partner.getEligibility().isInReviewOrNotApplicable()); } FinanceCheckSummaryResource(); FinanceCheckSummaryResource(Fi... | @Test public void isAllEligibilityAndViabilityInReview() { FinanceCheckSummaryResource resource = newFinanceCheckSummaryResource() .withPartnerStatusResources(newFinanceCheckPartnerStatusResource() .withEligibility(parameter.eligibilityStates) .withViability(parameter.viabilityStates) .build(parameter.getNumberOfPartne... |
CompetitionParticipantResource { @JsonIgnore public long getAssessmentDaysLeft() { return DAYS.between(ZonedDateTime.now(clock), assessorDeadlineDate); } String getCompetitionName(); void setCompetitionName(String competitionName); Long getId(); void setId(Long id); Long getCompetitionId(); void setCompetitionId(Long ... | @Test public void getAssessmentDaysLeft() throws Exception { assertEquals(3, competitionParticipant.getAssessmentDaysLeft()); assertEquals(0, competitionParticipantEndingToday.getAssessmentDaysLeft()); assertEquals(0, competitionParticipantEndingTommorrow.getAssessmentDaysLeft()); assertEquals(-1, competitionParticipan... |
CompetitionParticipantResource { @JsonIgnore public long getAssessmentDaysLeftPercentage() { return getDaysLeftPercentage(getAssessmentDaysLeft(), DAYS.between(assessorAcceptsDate, assessorDeadlineDate)); } String getCompetitionName(); void setCompetitionName(String competitionName); Long getId(); void setId(Long id);... | @Test public void getAssessmentDaysLeftPercentage() throws Exception { assertEquals(50, competitionParticipant.getAssessmentDaysLeftPercentage()); assertEquals(100, competitionParticipantEndingToday.getAssessmentDaysLeftPercentage()); assertEquals(100, competitionParticipantEndingTommorrow.getAssessmentDaysLeftPercenta... |
CompetitionParticipantResource { @JsonIgnore public boolean isInAssessment() { return competitionStatus == IN_ASSESSMENT; } String getCompetitionName(); void setCompetitionName(String competitionName); Long getId(); void setId(Long id); Long getCompetitionId(); void setCompetitionId(Long competitionId); Long getUserId... | @Test public void isInAssessment() throws Exception { assertFalse(competitionParticipantCompetitionSetup.isInAssessment()); assertFalse(competitionParticipantReadyToOpen.isInAssessment()); assertFalse(competitionParticipantOpen.isInAssessment()); assertFalse(competitionParticipantAssessmentClosed.isAnUpcomingAssessment... |
CompetitionParticipantResource { @JsonIgnore public boolean isAnUpcomingAssessment() { return competitionStatus == READY_TO_OPEN || competitionStatus == OPEN || competitionStatus == CLOSED; } String getCompetitionName(); void setCompetitionName(String competitionName); Long getId(); void setId(Long id); Long getCompet... | @Test public void isAnUpcomingAssessment() throws Exception { assertFalse(competitionParticipantCompetitionSetup.isAnUpcomingAssessment()); assertTrue(competitionParticipantReadyToOpen.isAnUpcomingAssessment()); assertTrue(competitionParticipantOpen.isAnUpcomingAssessment()); assertFalse(competitionParticipantClosed.is... |
OrganisationPermissionRules { @PermissionRule(value = "READ", description = "User is invited to join the organisation") public boolean usersCanViewOrganisationsTheyAreInvitedTo(OrganisationResource organisation, UserResource user) { return inviteOrganisationRepository.findFirstByOrganisationIdAndInvitesUserId(organisat... | @Test public void usersCanViewOrganisationsTheyAreInvitedTo() { UserResource invitedUser = newUserResource().build(); UserResource notInvitedUser = newUserResource().build(); OrganisationResource organisation = newOrganisationResource().build(); when(inviteOrganisationRepository.findFirstByOrganisationIdAndInvitesUserI... |
AssessorProfileDeclarationModelPopulator extends AssessorProfileDeclarationBasePopulator { public AssessorProfileDeclarationViewModel populateModel(UserResource user, ProfileResource profile, Optional<Long> competitionId, boolean compAdminUser) { CompetitionResource competition = competitionId.map(id -> competitionRest... | @Test public void populateModel() throws Exception { CompetitionResource competition = newCompetitionResource() .withId(1L) .build(); UserResource user = newUserResource() .withId(2L) .withFirstName("Test") .withLastName("Tester") .withEmail("test@test.com") .withPhoneNumber("012345") .build(); AddressResource expected... |
AssessorProfileSkillsModelPopulator { public AssessorProfileSkillsViewModel populateModel(UserResource user, ProfileResource profile, Optional<Long> competitionId, boolean compAdminUser) { CompetitionResource competition = competitionId.map(id -> competitionRestService.getCompetitionById(id).getSuccess()) .orElse(null)... | @Test public void populateModel() { CompetitionResource competition = newCompetitionResource() .withId(1L) .build(); UserResource user = newUserResource() .withId(2L) .withFirstName("Test") .withLastName("Tester") .withEmail("test@test.com") .withPhoneNumber("012345") .build(); AddressResource expectedAddress = newAddr... |
CompetitionController { @GetMapping("overview") public String competitionOverview(final Model model, @PathVariable("competitionId") final long competitionId, UserResource loggedInUser) { final PublicContentItemResource publicContentItem = publicContentItemRestService.getItemByCompetitionId(competitionId).getSuccess(); ... | @Test public void competitionOverview() throws Exception { final long competitionId = 20L; final PublicContentItemResource publicContentItem = newPublicContentItemResource().build(); final CompetitionOverviewViewModel viewModel = new CompetitionOverviewViewModel(); when(publicContentItemRestService.getItemByCompetition... |
CompetitionController { @GetMapping("info/terms-and-conditions") public String termsAndConditions(@PathVariable("competitionId") final long competitionId, Model model) { CompetitionResource competition = competitionRestService.getCompetitionById(competitionId).getSuccess(); GrantTermsAndConditionsResource termsAndCondi... | @Test public void termsAndConditions() throws Exception { GrantTermsAndConditionsResource termsAndConditions = new GrantTermsAndConditionsResource("T&C", "special-terms-and-conditions", 3); final CompetitionResource competitionResource = newCompetitionResource() .withCompetitionTypeName("Competition name") .withTermsAn... |
CompetitionSearchController { @NotSecured("Not currently secured") @GetMapping public String publicContentSearch(Model model, @RequestParam(value = KEYWORDS_KEY, required = false) Optional<String> keywords, @RequestParam(value = INNOVATION_AREA_ID_KEY, required = false) Optional<Long> innovationAreaId, @RequestParam(va... | @Test public void publicContentSearch() throws Exception { CompetitionSearchViewModel competitionSearchViewModel = new CompetitionSearchViewModel(); when(competitionSearchPopulatorMock.createItemSearchViewModel(Optional.empty(), Optional.empty(), Optional.empty())).thenReturn(competitionSearchViewModel); mockMvc.perfor... |
ScopeViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<ScopeViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.SCOPE; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.SCOPE, populator.getType()); } |
SummaryViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<SummaryViewModel> { @Override protected void populateSection(SummaryViewModel model, PublicContentItemResource publicContentItemResource, PublicContentSectionResource section, Boolean nonIFS) { PublicContentResource publicContentResource = p... | @Test public void populateSection() { populator.populateSection(viewModel, publicContentItemResource, publicContentSectionResource, Boolean.FALSE); assertEquals("Summary", viewModel.getDescription()); assertEquals(FundingType.GRANT.getDisplayName(), viewModel.getFundingType()); assertEquals("5M", viewModel.getProjectSi... |
SummaryViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<SummaryViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.SUMMARY; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.SUMMARY, populator.getType()); } |
EligibilityViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<EligibilityViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.ELIGIBILITY; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.ELIGIBILITY, populator.getType()); } |
DatesViewModelPopulator extends AbstractPublicContentSectionViewModelPopulator<DatesViewModel> { @Override protected void populateSection(DatesViewModel model, PublicContentItemResource publicContentItemResource, PublicContentSectionResource section, Boolean nonIFS) { List<DateViewModel> publicContentDates = mapContent... | @Test public void populateSectionWithMilestonesFound() { when(milestoneRestService.getAllPublicMilestonesByCompetitionId(publicContentItemResource.getPublicContentResource().getCompetitionId())) .thenReturn(restSuccess(newMilestoneResource() .withDate(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now()) .with... |
OrganisationController { @GetMapping("/find-by-id/{organisationId}") public RestResult<OrganisationResource> findById(@PathVariable("organisationId") final Long organisationId) { return organisationService.findById(organisationId).toGetResponse(); } @GetMapping("/find-by-application-id/{applicationId}") RestResult<Set... | @Test public void findByIdShouldReturnOrganisation() throws Exception { when(organisationServiceMock.findById(1L)).thenReturn(serviceSuccess(newOrganisationResource().withId(1L).withName("uniqueOrganisationName").build())); mockMvc.perform(get("/organisation/find-by-id/1")) .andExpect(status().isOk()) .andExpect(jsonPa... |
DatesViewModelPopulator extends AbstractPublicContentSectionViewModelPopulator<DatesViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.DATES; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.DATES, populator.getType()); } |
HowToApplyViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<HowToApplyViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.HOW_TO_APPLY; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.HOW_TO_APPLY, populator.getType()); } |
SupportingInformationViewModelPopulator extends AbstractPublicContentGroupViewModelPopulator<SupportingInformationViewModel> { @Override public PublicContentSectionType getType() { return PublicContentSectionType.SUPPORTING_INFORMATION; } @Override PublicContentSectionType getType(); } | @Test public void getType() { assertEquals(PublicContentSectionType.SUPPORTING_INFORMATION, populator.getType()); } |
CompetitionSearchPopulator { public CompetitionSearchViewModel createItemSearchViewModel(Optional<Long> innovationAreaId, Optional<String> keywords, Optional<Integer> pageNumber) { CompetitionSearchViewModel viewModel = new CompetitionSearchViewModel(); viewModel.setInnovationAreas(categoryRestService.getInnovationArea... | @Test public void createItemSearchViewModel() throws Exception { Optional<Long> expectedInnovationAreaId = Optional.of(10L); Optional<String> expectedKeywords = Optional.of("test%20abc"); Optional<Integer> expectedPageNumber = Optional.of(1); RestResult<PublicContentItemPageResource> restResult = restSuccess(publicCont... |
OrganisationController { @PostMapping("/create-or-match") public RestResult<OrganisationResource> createOrMatch(@RequestBody OrganisationResource organisation) { return organisationCreationService.createOrMatch(organisation).toPostCreateResponse(); } @GetMapping("/find-by-application-id/{applicationId}") RestResult<Se... | @Test public void createOrMatch_callsOrganisationServiceAndReturnsResultWithNoHash() throws Exception { OrganisationResource organisationResource = newOrganisationResource().build(); Gson gson = new Gson(); String json = gson.toJson(organisationResource, OrganisationResource.class); when(organisationInitialCreationServ... |
CompetitionOverviewPopulator { public CompetitionOverviewViewModel populateViewModel(PublicContentItemResource publicContentItemResource, boolean userIsLoggedIn) { CompetitionOverviewViewModel viewModel = new CompetitionOverviewViewModel(); viewModel.setCompetitionOpenDate(publicContentItemResource.getCompetitionOpenDa... | @Test public void populateViewModelTest_Default() throws Exception { PublicContentResource publicContentResource = newPublicContentResource() .withShortDescription("Short description") .withCompetitionId(23523L) .build(); CompetitionOverviewViewModel viewModel = populator.populateViewModel(setupPublicContent(publicCont... |
OrganisationController { @GetMapping("/by-user-and-application-id/{userId}/{applicationId}") public RestResult<OrganisationResource> getByUserAndApplicationId(@PathVariable("userId") final long userId, @PathVariable("applicationId") final long applicationId) { return organisationService.getByUserAndApplicationId(userId... | @Test public void getByUserAndApplicationId() throws Exception { when(organisationServiceMock.getByUserAndApplicationId(1L, 2L)).thenReturn(serviceSuccess(newOrganisationResource().withId(1L).withName("uniqueOrganisationName").build())); mockMvc.perform(get("/organisation/by-user-and-application-id/1/2")) .andExpect(st... |
PublicContentItemViewModelMapper { public PublicContentItemViewModel mapToViewModel(PublicContentItemResource publicContentItemResource) { PublicContentItemViewModel publicContentItemViewModel = new PublicContentItemViewModel(); publicContentItemViewModel.setCompetitionTitle(publicContentItemResource.getCompetitionTitl... | @Test public void mapToViewModel_expectedResourceVariablesAreMappedToViewModel() throws Exception { String eligibilitySummary = "eligibility summary"; String shortDescription = "short description"; Long competitionId = 123L; ZonedDateTime openDate = ZonedDateTime.now().minusDays(3L); ZonedDateTime closedDate = ZonedDat... |
AcceptGrantsInviteController { @GetMapping("/{hash}") public String inviteEntryPage( @PathVariable final long projectId, @PathVariable final String hash, HttpServletResponse response, Model model, UserResource loggedInUser) { RestResult<String> result = find(inviteByHash(projectId, hash)).andOnSuccess((invite) -> { Val... | @Test public void inviteEntryPage() throws Exception { String hash = "hash"; long projectId = 1L; SentGrantsInviteResource invite = newSentGrantsInviteResource() .withStatus(SENT) .withEmail("plonker@gmail.com") .build(); when(grantsInviteRestService.getInviteByHash(projectId, hash)).thenReturn(restSuccess(invite)); lo... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_PROJECT_DETAILS_SECTION", description = "A partner can access the Project Details section when their Companies House data is complete or not required") public boolean partnerCanAccessProjectDetailsSection(ProjectCompositeId projectCompositeId, UserResource ... | @Test public void projectDetailsSectionAccess() { assertScenariosForSections(SetupSectionAccessibilityHelper::canAccessProjectDetailsSection, () -> rules.partnerCanAccessProjectDetailsSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.getId()); }
@Test public void... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_PROJECT_MANAGER_PAGE", description = "A lead can access the Project Manager " + "page when their Companies House data is complete or not required, and the Grant Offer Letter has not yet been generated") public boolean leadCanAccessProjectManagerPage(Project... | @Test public void projectManagerPageAccess() { assertLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::leadCanAccessProjectManagerPage, () -> rules.leadCanAccessProjectManagerPage(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService, times(2)).getById(activeProject.getId()); }
@Test pu... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_PROJECT_ADDRESS_PAGE", description = "A lead can access the Project Address " + "page when their Companies House data is complete or not required, and the Grant Offer Letter has not yet been generated") public boolean leadCanAccessProjectAddressPage(Project... | @Test public void projectAddressPageAccess() { assertLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::leadCanAccessProjectAddressPage, () -> rules.leadCanAccessProjectAddressPage(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService, times(2)).getById(activeProject.getId()); }
@Test pu... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_FINANCE_CONTACT_PAGE", description = "A partner can access the Finance Contact " + "page when their Companies House data is complete or not required, and the Grant Offer Letter has not yet been generated") public boolean partnerCanAccessFinanceContactPage(P... | @Test public void financeContactPageAccess() { assertNonLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessFinanceContactPage, () -> rules.partnerCanAccessFinanceContactPage(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.getId()); }
@Test public voi... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_PARTNER_PROJECT_LOCATION_PAGE", description = "A partner can access the partner project location " + "page when their Companies House data is complete or not required, and the Monitoring Officer has not yet been assigned") public boolean partnerCanAccessPro... | @Test public void partnerProjectLocationPageAccess() { setUpPartnerProjectLocationRequiredMocking(); assertNonLeadPartnerSuccessfulAccess((setupSectionAccessibilityHelper, organisation) -> setupSectionAccessibilityHelper.canAccessPartnerProjectLocationPage(organisation, true), () -> rules.partnerCanAccessProjectLocatio... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_MONITORING_OFFICER_SECTION", description = "A partner can access the Monitoring Officer " + "section when their Companies House details are complete or not required, and the Project Details have been submitted") public boolean partnerCanAccessMonitoringOffi... | @Test public void monitoringOfficerSectionAccess() { setUpPartnerProjectLocationRequiredMocking(); assertNonLeadPartnerSuccessfulAccess((setupSectionAccessibilityHelper, organisation) -> setupSectionAccessibilityHelper.canAccessMonitoringOfficerSection(organisation, true), () -> rules.partnerCanAccessMonitoringOfficerS... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_BANK_DETAILS_SECTION", description = "A partner can access the Bank Details " + "section when their Companies House details are complete or not required, and they have a Finance Contact " + "available for their Organisation") public boolean partnerCanAccess... | @Test public void bankDetailsSectionAccess() { assertNonLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessBankDetailsSection, () -> rules.partnerCanAccessBankDetailsSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService, times(2)).getById(activeProject.getId()); }
@Test ... |
OrganisationController { @GetMapping("/by-user-and-project-id/{userId}/{projectId}") public RestResult<OrganisationResource> getByUserAndProjectId(@PathVariable("userId") final long userId, @PathVariable("projectId") final long projectId) { return organisationService.getByUserAndProjectId(userId, projectId).toGetRespon... | @Test public void getByUserAndProjectId() throws Exception { when(organisationServiceMock.getByUserAndProjectId(1L, 2L)).thenReturn(serviceSuccess(newOrganisationResource().withId(1L).withName("uniqueOrganisationName").build())); mockMvc.perform(get("/organisation/by-user-and-project-id/1/2")) .andExpect(status().isOk(... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_SPEND_PROFILE_SECTION", description = "A partner can access the Spend Profile " + "section when their Companies House details are complete or not required, the Project Details have been submitted, " + "and the Organisation's Bank Details have been approved ... | @Test public void spendProfileSectionAccess() { assertNonLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessSpendProfileSection, () -> rules.partnerCanAccessSpendProfileSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.getId()); }
@Test public ... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_TOTAL_SPEND_PROFILE_SECTION", description = "Only the project manager can access the Spend Profile " + "section when their Companies House details are complete or not required, the Project Details have been submitted, " + "and the Organisation's Bank Detail... | @Test public void projectManagerTotalSpendProfileSectionAccess() { assertLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessSpendProfileSection, () -> rules.projectManagerCanAccessSpendProfileSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.ge... |
SetupSectionsPermissionRules { @PermissionRule(value = "EDIT_SPEND_PROFILE_SECTION", description = "A partner can edit their own Spend Profile " + "section when their Companies House details are complete or not required, the Project Details have been submitted, " + "and the Organisation's Bank Details have been approve... | @Test public void editSpendProfileSectionAccess() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(activeProject.getId(), 22L); assertNonLeadPartnerSuccessfulAccess((setupSectionAccessibilityHelper, organisation) -> setupSectionAccessibilityHelper.canEditSpendProfileS... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_DOCUMENTS_SECTION", description = "A lead can access Documents section. A partner can access Documents " + "section if their Companies House information is unnecessary or complete") public boolean canAccessDocumentsSection(ProjectCompositeId projectComposit... | @Test public void documentsSectionAccessLead() { assertLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessDocumentsSection, () -> rules.canAccessDocumentsSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.getId()); }
@Test public void documentsS... |
SetupSectionsPermissionRules { @PermissionRule(value = "EDIT_DOCUMENTS_SECTION", description = "A project manager can edit Documents section") public boolean projectManagerCanEditDocumentsSection(ProjectCompositeId projectCompositeId, UserResource user) { return isProjectManager(projectCompositeId.id(), user); } @Perm... | @Test public void projectManagerCanEditDocumentsSection() { when(projectService.isProjectManager(user.getId(), activeProject.getId())).thenReturn(true); assertTrue(rules.projectManagerCanEditDocumentsSection(ProjectCompositeId.id(activeProject.getId()), user)); } |
OrganisationServiceImpl extends BaseTransactionalService implements OrganisationService { @Override @Transactional public ServiceResult<OrganisationResource> update(final OrganisationResource organisationResource) { return serviceSuccess(organisationMapper.mapToResource(createNewOrganisation(organisationResource))); } ... | @Test public void update() throws Exception { } |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_PROJECT_TEAM_STATUS", description = "A partner can access the Project Team Status page when the project is in a correct state to do so") public boolean partnerCanAccessProjectTeamStatus(ProjectCompositeId projectCompositeId, UserResource user) { return isPr... | @Test public void projectTeamStatusAccessUnavailableForWithdrawnProject() { assertLeadPartnerWithdrawnProjectAccess(() -> rules.partnerCanAccessProjectTeamStatus(ProjectCompositeId.id(withdrawnProject.getId()), user)); verify(projectService).getById(withdrawnProject.getId()); } |
CompaniesHouseApiServiceImpl implements CompaniesHouseApiService { @Override public ServiceResult<List<OrganisationSearchResult>> searchOrganisations(String encodedSearchText) { return decodeString(encodedSearchText).andOnSuccess(decodedSearchText -> { JsonNode companiesResources = restGet(COMPANIES_HOUSE_SEARCH_PATH, ... | @Test public void searchOrganisations() { Map<String, Object> companyResultMap = companyResultMap(); JsonNode resultNode = new ObjectMapper().valueToTree(asMap("items", asList(companyResultMap))); ResponseEntity<JsonNode> response = new ResponseEntity<JsonNode>(resultNode, HttpStatus.OK); when(adapter.restGetEntity(sea... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_GRANT_OFFER_LETTER_SECTION", description = "A lead partner can access the Grant Offer Letter " + "section when all other sections are complete and a Grant Offer Letter has been generated by the internal team") public boolean partnerCanAccessGrantOfferLetter... | @Test public void grantOfferLetterSectionAccess() { assertNonLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessGrantOfferLetterSection, () -> rules.partnerCanAccessGrantOfferLetterSection(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject.getId()); }
@... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_SIGNED_GRANT_OFFER_LETTER", description = "A lead partner can view and download signed grant offer letter document") public boolean leadPartnerAccessToSignedGrantOfferLetter(ProjectCompositeId projectCompositeId, UserResource user) { return doSectionCheck(p... | @Test public void signedGrantOfferLetterSuccessfulAccessByLead() { assertLeadPartnerSuccessfulAccess(SetupSectionAccessibilityHelper::canAccessGrantOfferLetterSection, () -> rules.leadPartnerAccessToSignedGrantOfferLetter(ProjectCompositeId.id(activeProject.getId()), user)); verify(projectService).getById(activeProject... |
SetupSectionsPermissionRules { @PermissionRule(value = "MARK_SPEND_PROFILE_INCOMPLETE", description = "All lead partners can mark partners spend profiles as incomplete") public boolean userCanMarkSpendProfileIncomplete(ProjectCompositeId projectCompositeId, UserResource user) { List<ProjectUserResource> projectLeadPart... | @Test public void markSpendProfileIncompleteAccess() { ProjectUserResource leadPartnerProjectUserResource = newProjectUserResource().withUser(user.getId()).build(); when(projectService.getLeadPartners(activeProject.getId())).thenReturn(singletonList(leadPartnerProjectUserResource)); assertTrue(rules.userCanMarkSpendPro... |
SetupSectionsPermissionRules { @PermissionRule(value = "IS_NOT_FROM_OWN_ORGANISATION", description = "A lead partner cannot mark their own spend profiles as incomplete") public boolean userCannotMarkOwnSpendProfileIncomplete(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { Organisatio... | @Test public void userCannotMarkOwnOrganisationAsIncomplete() { long userId = 1L; long organisationId = 2L; long projectId = 3L; UserResource userResource = newUserResource().withId(userId).build(); OrganisationResource organisationResource = newOrganisationResource().withId(organisationId).build(); when(organisationRe... |
SetupSectionsPermissionRules { @PermissionRule(value = "ACCESS_FINANCE_CHECKS_SECTION_EXTERNAL", description = "A partner can access the finance details " + " when their Companies House details are complete or not required, and the Project Details have been submitted") public boolean partnerCanAccessFinanceChecksSectio... | @Test public void partnerAccess() { long organisationId = 234L; UserResource user = newUserResource().withRolesGlobal(singletonList(PARTNER)).build(); BaseIntegrationTest.setLoggedInUser(user); OrganisationResource o = newOrganisationResource().withId(organisationId).build(); ProjectPartnerStatusResource partnerStatus ... |
SetupSectionAccessibilityHelper { public SectionAccess canEditSpendProfileSection(OrganisationResource userOrganisation, Long organisationIdFromUrl) { if (setupProgressChecker.isOfflineOrWithdrawn()) { return NOT_ACCESSIBLE; } if (canAccessSpendProfileSection(userOrganisation) == NOT_ACCESSIBLE) { return NOT_ACCESSIBLE... | @Test public void canEditSpendProfileSectionWhenCompaniesHouseDetailsNotComplete() { whenCompaniesHouseDetailsNotComplete((helper, organisation) -> helper.canEditSpendProfileSection(organisation, organisation.getId())); }
@Test public void canEditSpendProfileSectionWhenProjectDetailsNotSubmitted() { whenProjectDetailsN... |
SetupSectionAccessibilityHelper { public SectionAccess canAccessBankDetailsSection(OrganisationResource organisation) { if (organisation.isInternational()) { return NOT_ACCESSIBLE; } if (setupProgressChecker.isOfflineOrWithdrawn()) { return NOT_ACCESSIBLE; } if (!isCompaniesHouseSectionIsUnnecessaryOrComplete(organisat... | @Test public void canAccessBankDetailsSection() { when(setupProgressChecker.isOfflineOrWithdrawn()).thenReturn(false); when(setupProgressChecker.isCompaniesHouseDetailsComplete(organisation)).thenReturn(true); when(setupProgressChecker.isOrganisationRequiringFunding(organisation)).thenReturn(true); when(setupProgressCh... |
SetupStatusViewModelPopulator extends AsyncAdaptor { public SetupStatusViewModel populateViewModel(long projectId, UserResource loggedInUser) { ProjectResource project = projectService.getById(projectId); boolean monitoringOfficer = monitoringOfficerService.isMonitoringOfficerOnProject(projectId, loggedInUser.getId()).... | @Test public void viewProjectSetupStatusWithGOLApproved() { ProjectTeamStatusResource teamStatus = newProjectTeamStatusResource(). withProjectLeadStatus(newProjectPartnerStatusResource(). withProjectDetailsStatus(COMPLETE). withProjectTeamStatus(COMPLETE). withBankDetailsStatus(COMPLETE). withFinanceChecksStatus(COMPLE... |
ProjectManagerController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_MANAGER_PAGE')") @PostMapping(value = "/{projectId}/team/project-manager") public String updateProjectManager(@PathVariable("projectId") final long projectId, Model model, @Valid... | @Test public void updateProjectManager() throws Exception { long projectId = 123L; long projectManagerUserId = 456L; when(projectDetailsService.updateProjectManager(projectId, projectManagerUserId)).thenReturn(serviceSuccess()); mockMvc.perform(post("/project/{id}/team/project-manager", projectId) .param("projectManage... |
FinanceContactController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CONTACT_PAGE')") @PostMapping(value = "/{projectId}/team/finance-contact/organisation/{organisationId}") public String updateFinanceContact(@PathVariable("projectId") final long ... | @Test public void updateFinanceContact() throws Exception { long projectId = 123L; long financeContactUserId = 456L; long organisationId = 789L; ProjectOrganisationCompositeId composite = new ProjectOrganisationCompositeId(projectId, organisationId); when(projectDetailsService.updateFinanceContact(composite, financeCon... |
FileFunctions { public static final Path pathElementsToPath(List<String> pathElements) { return pathElementsToFile(pathElements).toPath(); } private FileFunctions(); static final String pathElementsToPathString(List<String> pathElements); static final List<String> pathStringToPathElements(final String pathString); sta... | @Test public void testPathElementsToPath() { assertEquals("path" + separator + "to" + separator + "file", FileFunctions.pathElementsToPath(asList("path", "to", "file")).toString()); }
@Test public void testPathElementsToPathWithLeadingSeparator() { assertEquals(separator + "path" + separator + "to" + separator + "file"... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @GetMapping("/{projectId}/team") public String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form, BindingResult bindingResult, @... | @Test public void viewProjectTeam() throws Exception { UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); long projectId = 999L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); when(populator.populate(projectId, loggedInUser)).thenReturn(expected); MvcResult result =... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "add-team-member") public String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form, Bind... | @Test public void openAddTeamMemberForm() throws Exception { UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); long projectId = 999L; long organisationId = 3L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); when(populator.populate(projectId, loggedInUser)).thenRetu... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "close-add-team-member-form") public String closeAddTeamMemberForm(@PathVariable("projectId") final long projectI... | @Test public void closeAddTeamMemberForm() throws Exception { long projectId = 999L; mockMvc.perform(post("/project/{id}/team", projectId) .param("close-add-team-member-form", "")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(String.format("/project/%d/team", projectId))) .andReturn(); } |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "invite-to-project") public String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form, BindingRe... | @Test public void inviteToProject() throws Exception { UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); long projectId = 999L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); String email = "someone@gmail.com"; String userName = "Some One"; ProjectResource projectR... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "resend-invite") public String resendInvite(@PathVariable("projectId") final long projectId, @RequestParam("resen... | @Test public void resendInvite() throws Exception { long projectId = 4L; long organisationId = 21L; long inviteId = 3L; String invitedUserName = "test"; String invitedUserEmail = "test@test.com"; OrganisationResource leadOrganisation = newOrganisationResource().withName("Lead Organisation").build(); List<ProjectUserInv... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "remove-team-member") public String removeUser(@PathVariable("projectId") final long projectId, @RequestParam("re... | @Test public void removeUser() throws Exception { UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); long userId = 444L; long projectId = 555L; when(projectTeamRestService.removeUser(projectId, userId)).thenReturn(restSuccess()); mockMvc.perform(post("/project/" + projectId + "/team")... |
ProjectTeamController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_TEAM_SECTION')") @PostMapping(value = "/{projectId}/team", params = "remove-invite") public String removeInvite(@PathVariable("projectId") final long projectId, @RequestParam("remov... | @Test public void removeInvite() throws Exception { long inviteId = 777L; long projectId = 888L; when(projectTeamRestService.removeInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/project/" + projectId + "/team") .param("remove-invite", String.valueOf(inviteId))) .andExpect(status().is3xxR... |
ProjectTeamViewModelPopulator { public ProjectTeamViewModel populate(long projectId, UserResource loggedInUser) { ProjectResource project = projectService.getById(projectId); boolean isMonitoringOfficer = monitoringOfficerRestService.isMonitoringOfficerOnProject(projectId, loggedInUser.getId()).getSuccess(); List<Proje... | @Test public void populate() { UserResource loggedInUser = newUserResource().withId(123L).build(); CompetitionResource competition = newCompetitionResource() .withName("Imaginative competition name") .build(); ProjectResource project = newProjectResource() .withCompetition(competition.getId()) .withName("Imaginative pr... |
ProjectDetailsStartDateViewModel implements BasicProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsStartDateViewModel(ProjectResource project, CompetitionResource competitionResource); Long getApplicationId(); Long getProjectId(); String getProjectName(); LocalDate get... | @Test public void testKtpCompetition() { ProjectResource projectResource = ProjectResourceBuilder.newProjectResource() .withDuration(15L).build(); CompetitionResource competitionResource = CompetitionResourceBuilder.newCompetitionResource() .withFundingType(FundingType.KTP).build(); ProjectDetailsStartDateViewModel vie... |
ProjectDetailsViewModel { public String getLocationForPartnerOrganisation(Long organisationId) { return partnerOrganisations.stream() .filter(partnerOrganisation -> partnerOrganisation.getOrganisation().equals(organisationId)) .findFirst() .map(partnerOrg -> { Optional<OrganisationResource> organisationResource = organ... | @Test public void shouldShowPostcodeForLocationGivenNotInternational() { List<OrganisationResource> organisations = Collections.emptyList(); PartnerOrganisationResource partnerOrg = new PartnerOrganisationResource(); partnerOrg.setOrganisation(ORG_ID); partnerOrg.setPostcode(POSTCODE); List<PartnerOrganisationResource>... |
CompaniesHouseApiServiceImpl implements CompaniesHouseApiService { @Override public ServiceResult<OrganisationSearchResult> getOrganisationById(String id) { LOG.debug("getOrganisationById " + id); return ofNullable(restGet("company/" + id, JsonNode.class)). map(jsonNode -> serviceSuccess(companyProfileMapper(jsonNode))... | @Test public void searchCompany() { Map<String, Object> companyMap = companyMap(); JsonNode resultNode = new ObjectMapper().valueToTree(companyMap); ResponseEntity<JsonNode> response = new ResponseEntity<JsonNode>(resultNode, HttpStatus.OK); when(adapter.restGetEntity("baseurl/company/123", JsonNode.class)).thenReturn(... |
ProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsViewModel(ProjectResource project, UserResource currentUser,
List<Long> usersPartnerOrganisations,
List<OrganisationResource> organisatio... | @Test public void testKtpCompetition() { competitionResource = CompetitionResourceBuilder.newCompetitionResource().withFundingType(FundingType.KTP).build(); ProjectDetailsViewModel viewModel = new ProjectDetailsViewModel(project, currentUser, usersPartnerOrganisations, null, null, leadOrganisation, userIsLeadPartner, s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.