@Test public void testValidationWithNameDuplicates() { GatewayV4Request gatewayJson = new GatewayV4Request(); GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request(); topology1.setTopologyName("Apple"); GatewayTopologyV4Request topology2 = new GatewayTopologyV4Request(); topology2.setTopologyName("Apple"); GatewayTopologyV4Request topology3 = new GatewayTopologyV4Request(); topology3.setTopologyName("Banana"); gatewayJson.setTopologies(Arrays.asList(topology1, topology2, topology3)); ValidationResult result = underTest.validate(gatewayJson); assertEquals(State.ERROR, result.getState()); assertTrue(result.getFormattedErrors().contains("Apple")); }
@Override public ValidationResult validate(GatewayV4Request subject) { ValidationResultBuilder validationResultBuilder = ValidationResult.builder(); if (CollectionUtils.isEmpty(subject.getTopologies())) { return validationResultBuilder.error("No topology is defined in gateway request. Please define a topology in " + "'gateway.topologies'.").build(); } validateTopologyNames(subject, validationResultBuilder); return validationResultBuilder.build(); }
GatewayV4RequestValidator implements Validator<GatewayV4Request> { @Override public ValidationResult validate(GatewayV4Request subject) { ValidationResultBuilder validationResultBuilder = ValidationResult.builder(); if (CollectionUtils.isEmpty(subject.getTopologies())) { return validationResultBuilder.error("No topology is defined in gateway request. Please define a topology in " + "'gateway.topologies'.").build(); } validateTopologyNames(subject, validationResultBuilder); return validationResultBuilder.build(); } }
GatewayV4RequestValidator implements Validator<GatewayV4Request> { @Override public ValidationResult validate(GatewayV4Request subject) { ValidationResultBuilder validationResultBuilder = ValidationResult.builder(); if (CollectionUtils.isEmpty(subject.getTopologies())) { return validationResultBuilder.error("No topology is defined in gateway request. Please define a topology in " + "'gateway.topologies'.").build(); } validateTopologyNames(subject, validationResultBuilder); return validationResultBuilder.build(); }  }
GatewayV4RequestValidator implements Validator<GatewayV4Request> { @Override public ValidationResult validate(GatewayV4Request subject) { ValidationResultBuilder validationResultBuilder = ValidationResult.builder(); if (CollectionUtils.isEmpty(subject.getTopologies())) { return validationResultBuilder.error("No topology is defined in gateway request. Please define a topology in " + "'gateway.topologies'.").build(); } validateTopologyNames(subject, validationResultBuilder); return validationResultBuilder.build(); }  @Override ValidationResult validate(GatewayV4Request subject); }
GatewayV4RequestValidator implements Validator<GatewayV4Request> { @Override public ValidationResult validate(GatewayV4Request subject) { ValidationResultBuilder validationResultBuilder = ValidationResult.builder(); if (CollectionUtils.isEmpty(subject.getTopologies())) { return validationResultBuilder.error("No topology is defined in gateway request. Please define a topology in " + "'gateway.topologies'.").build(); } validateTopologyNames(subject, validationResultBuilder); return validationResultBuilder.build(); }  @Override ValidationResult validate(GatewayV4Request subject);  }