@Test public void testWithInvalidKnoxServiceAndNoTopologyName() { String invalidService = "INVALID_SERVICE"; GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request(); gatewayTopologyJson.setExposedServices(Collections.singletonList(invalidService)); when(exposedServiceListValidator.validate(anyList())).thenReturn(new ValidationResultBuilder().error(invalidService).build()); ValidationResult result = underTest.validate(gatewayTopologyJson); assertEquals(State.ERROR, result.getState()); assertEquals(2L, result.getErrors().size()); assertTrue(result.getErrors().get(0).contains(invalidService)); assertTrue(result.getErrors().get(1).contains("topologyName must be set in gateway topology.")); }
@Override public ValidationResult validate(GatewayTopologyV4Request subject) { ValidationResult topologyNameResult = ValidationResult.builder() .ifError(() -> StringUtils.isBlank(subject.getTopologyName()), "topologyName must be set in gateway topology.") .build(); return Optional.ofNullable(subject.getExposedServices()) .map(exposedServiceListValidator::validate) .map(vr -> vr.merge(topologyNameResult)) .orElse(topologyNameResult); }
GatewayTopologyV4RequestValidator implements Validator<GatewayTopologyV4Request> { @Override public ValidationResult validate(GatewayTopologyV4Request subject) { ValidationResult topologyNameResult = ValidationResult.builder() .ifError(() -> StringUtils.isBlank(subject.getTopologyName()), "topologyName must be set in gateway topology.") .build(); return Optional.ofNullable(subject.getExposedServices()) .map(exposedServiceListValidator::validate) .map(vr -> vr.merge(topologyNameResult)) .orElse(topologyNameResult); } }
GatewayTopologyV4RequestValidator implements Validator<GatewayTopologyV4Request> { @Override public ValidationResult validate(GatewayTopologyV4Request subject) { ValidationResult topologyNameResult = ValidationResult.builder() .ifError(() -> StringUtils.isBlank(subject.getTopologyName()), "topologyName must be set in gateway topology.") .build(); return Optional.ofNullable(subject.getExposedServices()) .map(exposedServiceListValidator::validate) .map(vr -> vr.merge(topologyNameResult)) .orElse(topologyNameResult); } GatewayTopologyV4RequestValidator(ExposedServiceListValidator exposedServiceListValidator); }
GatewayTopologyV4RequestValidator implements Validator<GatewayTopologyV4Request> { @Override public ValidationResult validate(GatewayTopologyV4Request subject) { ValidationResult topologyNameResult = ValidationResult.builder() .ifError(() -> StringUtils.isBlank(subject.getTopologyName()), "topologyName must be set in gateway topology.") .build(); return Optional.ofNullable(subject.getExposedServices()) .map(exposedServiceListValidator::validate) .map(vr -> vr.merge(topologyNameResult)) .orElse(topologyNameResult); } GatewayTopologyV4RequestValidator(ExposedServiceListValidator exposedServiceListValidator); @Override ValidationResult validate(GatewayTopologyV4Request subject); }
GatewayTopologyV4RequestValidator implements Validator<GatewayTopologyV4Request> { @Override public ValidationResult validate(GatewayTopologyV4Request subject) { ValidationResult topologyNameResult = ValidationResult.builder() .ifError(() -> StringUtils.isBlank(subject.getTopologyName()), "topologyName must be set in gateway topology.") .build(); return Optional.ofNullable(subject.getExposedServices()) .map(exposedServiceListValidator::validate) .map(vr -> vr.merge(topologyNameResult)) .orElse(topologyNameResult); } GatewayTopologyV4RequestValidator(ExposedServiceListValidator exposedServiceListValidator); @Override ValidationResult validate(GatewayTopologyV4Request subject);  }