Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit 071520c

Browse files
author
changqin26
committed
Negative and positive unit tests pass.
1 parent 804106c commit 071520c

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.adminshell.aas.v3.model.validator;
2+
3+
import io.adminshell.aas.v3.model.Referable;
4+
import org.junit.Test;
5+
6+
import java.util.ArrayList;
7+
8+
import static org.junit.Assert.assertTrue;
9+
import static org.junit.Assert.fail;
10+
11+
/**
12+
* Tests the following constraint:
13+
* <p>
14+
* <i> An attribute with data type "string" is not allowed to be empty. </i>
15+
* </p>
16+
*
17+
* @author bader, chang
18+
*
19+
*/
20+
21+
public class TestAASd_100 {
22+
@Test
23+
public void idShortWithNotAllowedCharacters() throws ValidationException {
24+
Referable wrongReferable = ConstraintTestHelper.createSubmodel(new ArrayList<>());
25+
26+
27+
wrongReferable.setIdShort("");
28+
try {
29+
ShaclValidator.getInstance().validate(wrongReferable);
30+
fail();
31+
} catch (ValidationException e) {
32+
assertTrue(e.getMessage().endsWith("starting mandatory with a letter. I.e. [a-zA-Z][a-zA-Z0-9_]+."));
33+
}
34+
35+
36+
}
37+
38+
@Test
39+
public void idShortWithAllowedCharacters() throws ValidationException {
40+
Referable referable = ConstraintTestHelper.createSubmodel(new ArrayList<>());
41+
referable.setIdShort("id_Short");
42+
ShaclValidator.getInstance().validate(referable);
43+
}
44+
}

0 commit comments

Comments
 (0)