Total Complexity | 3 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | package com.hltech.vaunt.validator; |
||
10 | @Data |
||
11 | public class ValidationResult { |
||
12 | private final boolean isValid; |
||
13 | private final String description; |
||
14 | private final List<ValidationError> errors; |
||
15 | |||
16 | static ValidationResult success(Contract expectation) { |
||
17 | return new ValidationResult( |
||
18 | true, |
||
19 | String.format("Matching contract: %s %s, %s", |
||
20 | expectation.getDestinationType(), |
||
21 | expectation.getDestinationName(), |
||
22 | expectation.getBody().getId()), |
||
23 | new ArrayList<>()); |
||
24 | } |
||
25 | |||
26 | static ValidationResult failure(Contract expectation, ValidationError... errors) { |
||
27 | return new ValidationResult(false, String.format("Expectation: %s", expectation), Arrays.asList(errors)); |
||
28 | } |
||
29 | |||
30 | static ValidationResult failure(Contract expectation, Contract capability, ValidationError... errors) { |
||
31 | return new ValidationResult( |
||
32 | false, |
||
33 | String.format("Expectation: %s, Capability: %s", expectation, capability), |
||
34 | Arrays.asList(errors)); |
||
35 | } |
||
37 |