PolicyCombiningAlgIdValidatorImpl implements
		PolicyCombiningAlgIdValidator { @Override public String validateAndReturn(String policyCombiningAlgId) { if (!StringUtils.hasText(policyCombiningAlgId)) { throw new PolicyCombiningAlgIdNotFoundException( "policyCombiningAlgId must have a valid text!"); } if (combiningAlgs.keySet().contains(policyCombiningAlgId)) { policyCombiningAlgId = combiningAlgs.get(policyCombiningAlgId); } else { if (combiningAlgs.entrySet().stream().map(Entry::getValue) .noneMatch(policyCombiningAlgId::equals)) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append("The policyCombiningAlgId: ") .append(policyCombiningAlgId) .append(" is not a valid value!"); throw new InvalidPolicyCombiningAlgIdException( errorBuilder.toString()); } } return policyCombiningAlgId; }  @Override Map<String, String> getCombiningAlgs(); @Override String validateAndReturn(String policyCombiningAlgId);  }
@Test public void testValidateAndReturn_By_Key1() { assertEquals(VALUE1, sut.validateAndReturn(KEY1)); }
@Test public void testValidateAndReturn_By_Key2() { assertEquals(VALUE2, sut.validateAndReturn(KEY2)); }
@Test public void testValidateAndReturn_By_Value1() { assertEquals(VALUE1, sut.validateAndReturn(VALUE1)); }
@Test public void testValidateAndReturn_By_Value2() { assertEquals(VALUE2, sut.validateAndReturn(VALUE2)); }
@Test public void testValidateAndReturn_Throws_InvalidPolicyCombiningAlgIdException() { thrown.expect(InvalidPolicyCombiningAlgIdException.class); sut.validateAndReturn(INVALID); }
@Test public void testValidateAndReturn_Throws_PolicyCombiningAlgIdNotFoundException_By_Empty_String() { thrown.expect(PolicyCombiningAlgIdNotFoundException.class); sut.validateAndReturn(""); }
@Test public void testValidateAndReturn_Throws_PolicyCombiningAlgIdNotFoundException_By_Null() { thrown.expect(PolicyCombiningAlgIdNotFoundException.class); sut.validateAndReturn(null); }