-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Discriminator identity methods, error handling test cases
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/io/xlate/edi/internal/schema/implementation/DiscriminatorImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.xlate.edi.internal.schema.implementation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import java.util.Collections; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.xlate.edi.schema.implementation.Discriminator; | ||
|
||
class DiscriminatorImplTest { | ||
|
||
DiscriminatorImpl target; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
target = new DiscriminatorImpl(1, 2, Collections.singleton("50")); | ||
} | ||
|
||
@Test | ||
void testHashCode() { | ||
int expected = new DiscriminatorImpl(1, 2, Collections.singleton("50")).hashCode(); | ||
assertEquals(expected, target.hashCode()); | ||
} | ||
|
||
@Test | ||
void testEquals_Same() { | ||
assertEquals(target, target); | ||
} | ||
|
||
@Test | ||
void testEquals_Identical() { | ||
Discriminator identical = new DiscriminatorImpl(1, 2, Collections.singleton("50")); | ||
assertEquals(target, identical); | ||
} | ||
|
||
@Test | ||
void testEquals_NotInstance() { | ||
assertFalse(target.equals(null)); | ||
assertFalse(target.equals(new Object())); | ||
} | ||
|
||
@Test | ||
void testEquals_Different() { | ||
assertNotEquals(new DiscriminatorImpl(1, 2, Collections.singleton("60")), target); | ||
assertNotEquals(new DiscriminatorImpl(2, 2, Collections.singleton("50")), target); | ||
assertNotEquals(new DiscriminatorImpl(1, 3, Collections.singleton("50")), target); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
String expected = new DiscriminatorImpl(1, 2, Collections.singleton("50")).toString(); | ||
assertEquals(expected, target.toString()); | ||
} | ||
|
||
} |