|
1 | | -package org.openmetadata.service.util; |
2 | | - |
3 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | | -import static org.junit.jupiter.api.Assertions.assertNull; |
5 | | - |
6 | | -import java.util.UUID; |
7 | | -import org.junit.jupiter.api.Test; |
8 | | -import org.openmetadata.schema.entity.data.Glossary; |
9 | | - |
10 | | -class ValidatorUtilTest { |
11 | | - @Test |
12 | | - void testValidator() { |
13 | | - // Required parameters name, description, and id missing |
14 | | - Glossary glossary = new Glossary().withName("name").withDescription("description"); |
15 | | - assertEquals("[id must not be null]", ValidatorUtil.validate(glossary)); |
16 | | - |
17 | | - glossary.withId(UUID.randomUUID()).withName(null); |
18 | | - assertEquals("[name must not be null]", ValidatorUtil.validate(glossary)); |
19 | | - |
20 | | - glossary.withName("name").withDescription(null); |
21 | | - assertEquals("[description must not be null]", ValidatorUtil.validate(glossary)); |
22 | | - |
23 | | - // Invalid name |
24 | | - glossary.withName("invalid::Name").withDescription("description"); |
25 | | - assertEquals("[name must match \"^((?!::)[^><\"|\\x00-\\x1f])*$\"]", ValidatorUtil.validate(glossary)); |
26 | | - |
27 | | - // No error |
28 | | - glossary.withName("validName").withId(UUID.randomUUID()).withDescription("description"); |
29 | | - assertNull(ValidatorUtil.validate(glossary)); |
30 | | - } |
31 | | -} |
| 1 | +package org.openmetadata.service.util; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 5 | + |
| 6 | +import java.util.UUID; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import org.openmetadata.schema.entity.data.Glossary; |
| 9 | + |
| 10 | +class ValidatorUtilTest { |
| 11 | + @Test |
| 12 | + void testValidator() { |
| 13 | + // Required parameters name, description, and id missing |
| 14 | + Glossary glossary = new Glossary().withName("name").withDescription("description"); |
| 15 | + assertEquals("[id must not be null]", ValidatorUtil.validate(glossary)); |
| 16 | + |
| 17 | + glossary.withId(UUID.randomUUID()).withName(null); |
| 18 | + assertEquals("[name must not be null]", ValidatorUtil.validate(glossary)); |
| 19 | + |
| 20 | + glossary.withName("name").withDescription(null); |
| 21 | + assertEquals("[description must not be null]", ValidatorUtil.validate(glossary)); |
| 22 | + |
| 23 | + // Invalid name |
| 24 | + glossary.withName("invalid::Name").withDescription("description"); |
| 25 | + assertEquals("[name must match \"^((?!::)[^><\"|\\x00-\\x1f])*$\"]", ValidatorUtil.validate(glossary)); |
| 26 | + |
| 27 | + // No error |
| 28 | + glossary.withName("validName").withId(UUID.randomUUID()).withDescription("description"); |
| 29 | + assertNull(ValidatorUtil.validate(glossary)); |
| 30 | + } |
| 31 | +} |
0 commit comments