@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*Operation names must be unique.*") public void testDuplicateOperationNames() { validator.verifyUniqueOperationsName(Arrays.asList( createOperation("foo"), createOperation("FOo") )); }
void verifyUniqueOperationsName(List<Operation> operations) { Set<String> opNames = new HashSet<>(); for (Operation op : operations) { String opName = op.getName(); if (opName == null || opName.isEmpty()) throw new ValidationException("Operations must have names."); boolean unique = opNames.add(op.getName().toLowerCase()); if (!unique) throw new ValidationException("Operation names must be unique."); } }
AgendaValidator extends DataObjectValidator<Agenda, DataObjectRequest<Agenda>> { void verifyUniqueOperationsName(List<Operation> operations) { Set<String> opNames = new HashSet<>(); for (Operation op : operations) { String opName = op.getName(); if (opName == null || opName.isEmpty()) throw new ValidationException("Operations must have names."); boolean unique = opNames.add(op.getName().toLowerCase()); if (!unique) throw new ValidationException("Operation names must be unique."); } } }
AgendaValidator extends DataObjectValidator<Agenda, DataObjectRequest<Agenda>> { void verifyUniqueOperationsName(List<Operation> operations) { Set<String> opNames = new HashSet<>(); for (Operation op : operations) { String opName = op.getName(); if (opName == null || opName.isEmpty()) throw new ValidationException("Operations must have names."); boolean unique = opNames.add(op.getName().toLowerCase()); if (!unique) throw new ValidationException("Operation names must be unique."); } }  }
AgendaValidator extends DataObjectValidator<Agenda, DataObjectRequest<Agenda>> { void verifyUniqueOperationsName(List<Operation> operations) { Set<String> opNames = new HashSet<>(); for (Operation op : operations) { String opName = op.getName(); if (opName == null || opName.isEmpty()) throw new ValidationException("Operations must have names."); boolean unique = opNames.add(op.getName().toLowerCase()); if (!unique) throw new ValidationException("Operation names must be unique."); } }  @Override void validatePOST(DataObjectRequest<Agenda> request); AgendaValidator setJsonContext(JsonContext jsonContext); }
AgendaValidator extends DataObjectValidator<Agenda, DataObjectRequest<Agenda>> { void verifyUniqueOperationsName(List<Operation> operations) { Set<String> opNames = new HashSet<>(); for (Operation op : operations) { String opName = op.getName(); if (opName == null || opName.isEmpty()) throw new ValidationException("Operations must have names."); boolean unique = opNames.add(op.getName().toLowerCase()); if (!unique) throw new ValidationException("Operation names must be unique."); } }  @Override void validatePOST(DataObjectRequest<Agenda> request); AgendaValidator setJsonContext(JsonContext jsonContext);  }