Skip to content

Commit 3c27208

Browse files
committed
Validation Error Test
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
1 parent c6e7a75 commit 3c27208

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.api.test;
17+
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
20+
import io.serverlessworkflow.api.validation.ValidationError;
21+
import java.util.ArrayList;
22+
import java.util.Collection;
23+
import java.util.LinkedHashSet;
24+
import org.junit.jupiter.api.Test;
25+
26+
public class ValidationErrorTest {
27+
28+
@Test
29+
void duplicateTest() {
30+
31+
Collection<ValidationError> duplicatedErrors = addMessagesToCollection(new ArrayList<>());
32+
Collection<ValidationError> errors = addMessagesToCollection(new LinkedHashSet<>());
33+
34+
assertEquals(duplicatedErrors.size(), 3);
35+
assertEquals(errors.size(), 2);
36+
37+
assertEquals(duplicatedErrors.iterator().next().getMessage(), "This is the first message");
38+
assertEquals(errors.iterator().next().getMessage(), "This is the first message");
39+
}
40+
41+
private Collection<ValidationError> addMessagesToCollection(Collection<ValidationError> errors) {
42+
ValidationError first = new ValidationError();
43+
first.setMessage("This is the first message");
44+
ValidationError second = new ValidationError();
45+
second.setMessage("This is the duplicated message");
46+
ValidationError third = new ValidationError();
47+
third.setMessage("This is the duplicated message");
48+
errors.add(first);
49+
errors.add(second);
50+
errors.add(third);
51+
return errors;
52+
}
53+
}

0 commit comments

Comments
 (0)