### Question:
BasicUcitsConcentrationValidator implements ValidationEngine { @Override public ValidationResults validate(final ExistingPortfolio portfolio) { final Results results = new Results(portfolio); final BigDecimal porfolioValue = portfolio.getPortfolioValue(); final Map<String, TotalPerIssuer> totalPerIssuer = new HashMap<>(); results.getLines().forEach(l -> { if (!assetEligibilityProvider.isEligible(l.getAssetCode())) { l.addIssue(Severity.MANDATORY, RuleNames.ELIGIBILITY, "Asset not eligible."); } l.setAllocationWeight(BigDecimalUtil.divide(8, l.getValueInPortfolioCcy(), porfolioValue, BigDecimal.ROUND_HALF_UP)); totalPerIssuer.computeIfAbsent(assetDetailsProvider.getDetails(l.getAssetCode()).getUltimateIssuerCode(), TotalPerIssuer::new).add(l); }); final Total totalMediumConcentration = new Total(); final List<ValidatedPortfolioLine> mediumLines = new ArrayList<>(); totalPerIssuer.values().forEach(issuer -> { final BigDecimal totalWeight = issuer.getTotalWeight(); if (BigDecimalUtil.compareTo(totalWeight, maxConcentrationPerIssuer) > 0) { issuer.lines.forEach(line -> line.addIssue(Severity.MANDATORY, RuleNames.ISSUER_MAX_CONCENTRATION, "Concentration above " + BigDecimalUtil.movePoint(maxConcentrationPerIssuer, 2) + "% for " + issuer.getIssuer() + " [" + BigDecimalUtil.movePoint(totalWeight, 2) + "]")); } else if (BigDecimalUtil.compareTo(totalWeight, mediumConcentrationPerIssuer) > 0) { totalMediumConcentration.add(totalWeight); mediumLines.addAll(issuer.getLines()); } }); if (BigDecimalUtil.compareTo(totalMediumConcentration.getTotal(), maxForMediumConcentration) > 0) { mediumLines.forEach(line -> line.addIssue(Severity.MANDATORY, RuleNames.ISSUER_MEDIUM_CONCENTRATION, "Total medium concentration is above " + BigDecimalUtil.movePoint(maxForMediumConcentration, 2) + "% [" + BigDecimalUtil.movePoint(totalMediumConcentration.getTotal(), 2) + "]")); } return results; } BasicUcitsConcentrationValidator(final Builder builder); @Override ValidationResults validate(final ExistingPortfolio portfolio);  }### Answer:
@Test public void testValidateEmpty() { final BasicPortfolio bp = new BasicPortfolio(); final ValidationResults res = validator.validate(bp); assertThat(res).isNotNull(); assertThat(res.getLines()).isEmpty(); }
@Test public void testValidate1Line() { final BasicPortfolio bp = new BasicPortfolio(); bp.setPortfolioCcy("USD"); bp.setPortfolioValue(bd("8800")); final List<ExistingPortfolioLine> lines = new ArrayList<>(); lines.add(new BasicLine("IBM", "International Business Machine", bd("88"), bd("100"), bd("8800"))); bp.setLines(lines); final ValidationResults res = validator.validate(bp); assertThat(res).isNotNull(); assertThat(res.getLines()).hasSize(1); System.out.println(res); }