Skip to content

Commit d7ecbbf

Browse files
author
yevhenii-nadtochii
committed
Rollback the removed tests
1 parent 99e254a commit d7ecbbf

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

java-tests/runtime/src/test/kotlin/io/spine/validate/EntityIdSpec.kt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,72 @@ import org.junit.jupiter.api.assertDoesNotThrow
4444
@DisplayName(VALIDATION_SHOULD + "validate an entity ID")
4545
internal class EntityIdSpec : ValidationOfConstraintTest() {
4646

47+
@Nested inner class
48+
`in a command file and` {
49+
50+
@Test
51+
fun `find out that non-default message is valid`() {
52+
val state = assertDoesNotThrow {
53+
entityIdMsgFieldValue {
54+
value = newStringValue()
55+
}
56+
}
57+
assertValid(state)
58+
}
59+
60+
@Test
61+
fun `find out that default message is NOT valid`() {
62+
val msg = EntityIdMsgFieldValue.getDefaultInstance()
63+
assertNotValid(msg)
64+
}
65+
4766
@Test
4867
fun `find out that empty string is NOT valid`() {
4968
val msg = EntityIdStringFieldValue.getDefaultInstance()
5069
assertNotValid(msg)
5170
}
5271

72+
@Test
73+
fun `find out that non-empty string is valid`() {
74+
val state = assertDoesNotThrow {
75+
entityIdStringFieldValue {
76+
value = Identifier.newUuid()
77+
}
78+
}
79+
assertValid(state)
80+
}
81+
82+
@Test
83+
fun `provide a violation if is not valid`() {
84+
val msg = EntityIdMsgFieldValue.getDefaultInstance()
85+
assertSingleViolation(msg, MessageValidatorTestEnv.VALUE)
86+
}
87+
}
88+
89+
@Nested inner class
90+
`in a state and` {
91+
92+
@Test
93+
fun `consider it required by default`() {
94+
val stateWithDefaultId = AggregateState.getDefaultInstance()
95+
assertNotValid(stateWithDefaultId)
96+
}
97+
98+
@Test
99+
fun `match only the first field named 'id' or ending with '_id'`() {
100+
val onlyEntityIdSet = assertDoesNotThrow {
101+
// Only ID set.
102+
aggregateState {
103+
entityId = Identifier.newUuid()
104+
}
105+
}
106+
assertValid(onlyEntityIdSet)
107+
}
108+
109+
@Test
110+
fun `not consider it '(required)' if the option is set explicitly to false`() {
111+
val stateWithDefaultId = ProjectionState.getDefaultInstance()
112+
assertValid(stateWithDefaultId)
113+
}
114+
}
53115
}

0 commit comments

Comments
 (0)