@SuppressWarnings("unchecked") @Test public void testValidate() { String testLookupName = "testLookup"; List<InverseValuesLookupEntry> validEntries = new ArrayList<>(); validEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "inverseValue1")); validEntries.add(new InverseValuesLookupEntry("key2", "value2", "inverseKey2", "inverseValue2")); List<InverseValuesLookupEntry> emptyValueEntries = new ArrayList<>(); emptyValueEntries.add(new InverseValuesLookupEntry("key1", "", "inverseKey1", "inverseValue1")); emptyValueEntries.add(new InverseValuesLookupEntry("key2", "value2", "inverseKey2", "inverseValue2")); List<InverseValuesLookupEntry> emptyInverseValueEntries = new ArrayList<>(); emptyInverseValueEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "")); emptyInverseValueEntries.add(new InverseValuesLookupEntry("key2", "value2", "inverseKey2", "inverseValue2")); List<InverseValuesLookupEntry> duplicateKeyEntries = new ArrayList<>(); duplicateKeyEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "inverseValue1")); duplicateKeyEntries.add(new InverseValuesLookupEntry("key1", "value2", "inverseKey2", "inverseValue2")); List<InverseValuesLookupEntry> duplicateValuesEntries = new ArrayList<>(); duplicateValuesEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "inverseValue1")); duplicateValuesEntries.add(new InverseValuesLookupEntry("key2", "value1", "inverseKey2", "inverseValue2")); List<InverseValuesLookupEntry> duplicateInverseKeyEntries = new ArrayList<>(); duplicateInverseKeyEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "inverseValue1")); duplicateInverseKeyEntries.add(new InverseValuesLookupEntry("key2", "value2", "inverseKey1", "inverseValue2")); List<InverseValuesLookupEntry> duplicateInverseValuesEntries = new ArrayList<>(); duplicateInverseValuesEntries.add(new InverseValuesLookupEntry("key1", "value1", "inverseKey1", "inverseValue1")); duplicateInverseValuesEntries.add(new InverseValuesLookupEntry("key2", "value2", "inverseKey2", "inverseValue1")); Object[][] testData = { { validEntries, true, null }, { emptyValueEntries, false, "Empty value found in '" + testLookupName + "' lookup!" }, { emptyInverseValueEntries, false, "Empty inverse value found in '" + testLookupName + "' lookup!" }, { duplicateKeyEntries, false, "Duplicate key found in '" + testLookupName + "' lookup! [key : key1]" }, { duplicateValuesEntries, false, "Duplicate value found in '" + testLookupName + "' lookup! [values : value1]" }, { duplicateInverseKeyEntries, false, "Duplicate inverse key found in '" + testLookupName + "' lookup! [key : inverseKey1]" }, { duplicateInverseValuesEntries, false, "Duplicate inverse value found in '" + testLookupName + "' lookup! [values : inverseValue1]" } }; for (Object[] testDatum : testData) { List<InverseValuesLookupEntry> entries = (List<InverseValuesLookupEntry>) testDatum[0]; inverseValuesLookup.setEntries(entries); inverseValuesLookup.setName(testLookupName); LookupValidationResult res = inverseValuesLookup.validate(); assertEquals(testDatum[1], res.isValid()); assertEquals(testDatum[2], res.getErrorMessage()); } }
@Override @JsonIgnore public LookupValidationResult validate() { for (InverseValuesLookupEntry entry : entries) { if (entry.getKey() == null) { return new LookupValidationResult(false, "Key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getValue() == null || entry.getValue().isEmpty()) { return new LookupValidationResult(false, "Empty value found in '" + getName() + "' lookup!"); } if (entry.getInverseKey() == null) { return new LookupValidationResult(false, "Inverse key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getInverseValue() == null || entry.getInverseValue().isEmpty()) { return new LookupValidationResult(false, "Empty inverse value found in '" + getName() + "' lookup!"); } } for (int i = 0; i < entries.size(); i++) { for (int j = i + 1; j < entries.size(); j++) { if (Objects.equals(entries.get(i).getKey(), entries.get(j).getKey())) { return new LookupValidationResult(false, "Duplicate key found in '" + getName() + "' lookup! [key : " + entries.get(i).getKey() + "]"); } if (Objects.equals(entries.get(i).getValue(), entries.get(j).getValue())) { return new LookupValidationResult(false, "Duplicate value found in '" + getName() + "' lookup! [values : " + entries.get(i).getValue() + "]"); } if (Objects.equals(entries.get(i).getInverseKey(), entries.get(j).getInverseKey())) { return new LookupValidationResult(false, "Duplicate inverse key found in '" + getName() + "' lookup! [key : " + entries.get(i).getInverseKey() + "]"); } if (Objects.equals(entries.get(i).getInverseValue(), entries.get(j).getInverseValue())) { return new LookupValidationResult(false, "Duplicate inverse value found in '" + getName() + "' lookup! [values : " + entries.get(i).getInverseValue() + "]"); } } } return new LookupValidationResult(true, null); }
InverseValuesLookup extends AcmLookup<InverseValuesLookupEntry> { @Override @JsonIgnore public LookupValidationResult validate() { for (InverseValuesLookupEntry entry : entries) { if (entry.getKey() == null) { return new LookupValidationResult(false, "Key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getValue() == null || entry.getValue().isEmpty()) { return new LookupValidationResult(false, "Empty value found in '" + getName() + "' lookup!"); } if (entry.getInverseKey() == null) { return new LookupValidationResult(false, "Inverse key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getInverseValue() == null || entry.getInverseValue().isEmpty()) { return new LookupValidationResult(false, "Empty inverse value found in '" + getName() + "' lookup!"); } } for (int i = 0; i < entries.size(); i++) { for (int j = i + 1; j < entries.size(); j++) { if (Objects.equals(entries.get(i).getKey(), entries.get(j).getKey())) { return new LookupValidationResult(false, "Duplicate key found in '" + getName() + "' lookup! [key : " + entries.get(i).getKey() + "]"); } if (Objects.equals(entries.get(i).getValue(), entries.get(j).getValue())) { return new LookupValidationResult(false, "Duplicate value found in '" + getName() + "' lookup! [values : " + entries.get(i).getValue() + "]"); } if (Objects.equals(entries.get(i).getInverseKey(), entries.get(j).getInverseKey())) { return new LookupValidationResult(false, "Duplicate inverse key found in '" + getName() + "' lookup! [key : " + entries.get(i).getInverseKey() + "]"); } if (Objects.equals(entries.get(i).getInverseValue(), entries.get(j).getInverseValue())) { return new LookupValidationResult(false, "Duplicate inverse value found in '" + getName() + "' lookup! [values : " + entries.get(i).getInverseValue() + "]"); } } } return new LookupValidationResult(true, null); } }
InverseValuesLookup extends AcmLookup<InverseValuesLookupEntry> { @Override @JsonIgnore public LookupValidationResult validate() { for (InverseValuesLookupEntry entry : entries) { if (entry.getKey() == null) { return new LookupValidationResult(false, "Key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getValue() == null || entry.getValue().isEmpty()) { return new LookupValidationResult(false, "Empty value found in '" + getName() + "' lookup!"); } if (entry.getInverseKey() == null) { return new LookupValidationResult(false, "Inverse key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getInverseValue() == null || entry.getInverseValue().isEmpty()) { return new LookupValidationResult(false, "Empty inverse value found in '" + getName() + "' lookup!"); } } for (int i = 0; i < entries.size(); i++) { for (int j = i + 1; j < entries.size(); j++) { if (Objects.equals(entries.get(i).getKey(), entries.get(j).getKey())) { return new LookupValidationResult(false, "Duplicate key found in '" + getName() + "' lookup! [key : " + entries.get(i).getKey() + "]"); } if (Objects.equals(entries.get(i).getValue(), entries.get(j).getValue())) { return new LookupValidationResult(false, "Duplicate value found in '" + getName() + "' lookup! [values : " + entries.get(i).getValue() + "]"); } if (Objects.equals(entries.get(i).getInverseKey(), entries.get(j).getInverseKey())) { return new LookupValidationResult(false, "Duplicate inverse key found in '" + getName() + "' lookup! [key : " + entries.get(i).getInverseKey() + "]"); } if (Objects.equals(entries.get(i).getInverseValue(), entries.get(j).getInverseValue())) { return new LookupValidationResult(false, "Duplicate inverse value found in '" + getName() + "' lookup! [values : " + entries.get(i).getInverseValue() + "]"); } } } return new LookupValidationResult(true, null); }  }
InverseValuesLookup extends AcmLookup<InverseValuesLookupEntry> { @Override @JsonIgnore public LookupValidationResult validate() { for (InverseValuesLookupEntry entry : entries) { if (entry.getKey() == null) { return new LookupValidationResult(false, "Key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getValue() == null || entry.getValue().isEmpty()) { return new LookupValidationResult(false, "Empty value found in '" + getName() + "' lookup!"); } if (entry.getInverseKey() == null) { return new LookupValidationResult(false, "Inverse key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getInverseValue() == null || entry.getInverseValue().isEmpty()) { return new LookupValidationResult(false, "Empty inverse value found in '" + getName() + "' lookup!"); } } for (int i = 0; i < entries.size(); i++) { for (int j = i + 1; j < entries.size(); j++) { if (Objects.equals(entries.get(i).getKey(), entries.get(j).getKey())) { return new LookupValidationResult(false, "Duplicate key found in '" + getName() + "' lookup! [key : " + entries.get(i).getKey() + "]"); } if (Objects.equals(entries.get(i).getValue(), entries.get(j).getValue())) { return new LookupValidationResult(false, "Duplicate value found in '" + getName() + "' lookup! [values : " + entries.get(i).getValue() + "]"); } if (Objects.equals(entries.get(i).getInverseKey(), entries.get(j).getInverseKey())) { return new LookupValidationResult(false, "Duplicate inverse key found in '" + getName() + "' lookup! [key : " + entries.get(i).getInverseKey() + "]"); } if (Objects.equals(entries.get(i).getInverseValue(), entries.get(j).getInverseValue())) { return new LookupValidationResult(false, "Duplicate inverse value found in '" + getName() + "' lookup! [values : " + entries.get(i).getInverseValue() + "]"); } } } return new LookupValidationResult(true, null); }  @Override @JsonIgnore LookupValidationResult validate(); }
InverseValuesLookup extends AcmLookup<InverseValuesLookupEntry> { @Override @JsonIgnore public LookupValidationResult validate() { for (InverseValuesLookupEntry entry : entries) { if (entry.getKey() == null) { return new LookupValidationResult(false, "Key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getValue() == null || entry.getValue().isEmpty()) { return new LookupValidationResult(false, "Empty value found in '" + getName() + "' lookup!"); } if (entry.getInverseKey() == null) { return new LookupValidationResult(false, "Inverse key not found or have [null] value in '" + getName() + "' lookup!"); } if (entry.getInverseValue() == null || entry.getInverseValue().isEmpty()) { return new LookupValidationResult(false, "Empty inverse value found in '" + getName() + "' lookup!"); } } for (int i = 0; i < entries.size(); i++) { for (int j = i + 1; j < entries.size(); j++) { if (Objects.equals(entries.get(i).getKey(), entries.get(j).getKey())) { return new LookupValidationResult(false, "Duplicate key found in '" + getName() + "' lookup! [key : " + entries.get(i).getKey() + "]"); } if (Objects.equals(entries.get(i).getValue(), entries.get(j).getValue())) { return new LookupValidationResult(false, "Duplicate value found in '" + getName() + "' lookup! [values : " + entries.get(i).getValue() + "]"); } if (Objects.equals(entries.get(i).getInverseKey(), entries.get(j).getInverseKey())) { return new LookupValidationResult(false, "Duplicate inverse key found in '" + getName() + "' lookup! [key : " + entries.get(i).getInverseKey() + "]"); } if (Objects.equals(entries.get(i).getInverseValue(), entries.get(j).getInverseValue())) { return new LookupValidationResult(false, "Duplicate inverse value found in '" + getName() + "' lookup! [values : " + entries.get(i).getInverseValue() + "]"); } } } return new LookupValidationResult(true, null); }  @Override @JsonIgnore LookupValidationResult validate();  }