Skip to content

Commit

Permalink
#190 Added tests for new methods of UniqueId
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Mar 15, 2016
1 parent 270bf06 commit 289b85a
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions junit-tests/src/test/java/org/junit/gen5/engine/UniqueIdTests.java
Expand Up @@ -12,12 +12,16 @@

import static org.junit.gen5.api.Assertions.assertEquals;

import java.util.Optional;

import org.junit.gen5.api.Assertions;
import org.junit.gen5.api.Nested;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.UniqueId.Segment;

/**
* Microtests for class {@link UniqueId}
*
* @since 5.0
*/
class UniqueIdTests {
Expand All @@ -28,13 +32,37 @@ class UniqueIdTests {
class Creation {

@Test
void uniqueIdMustBeCreatedWithEngineId() {
UniqueId uniqueId = UniqueId.root("engine", ENGINE_ID);
void uniqueIdCanBeCreatedFromEngineId() {
UniqueId uniqueId = UniqueId.forEngine(ENGINE_ID);

assertEquals("[engine:junit5]", uniqueId.getUniqueString());
assertSegment(uniqueId.getSegments().get(0), "engine", "junit5");
}

@Test
void retrievingOptionalEngineId() {
UniqueId uniqueIdWithEngine = UniqueId.forEngine(ENGINE_ID);
assertEquals("junit5", uniqueIdWithEngine.getEngineId().get());

UniqueId uniqueIdWithoutEngine = UniqueId.root("root", "avalue");
assertEquals(Optional.empty(), uniqueIdWithoutEngine.getEngineId());
}

@Test
void uniqueIdCanBeCreatedFromTypeAndValue() {
UniqueId uniqueId = UniqueId.root("aType", "aValue");

assertEquals("[aType:aValue]", uniqueId.getUniqueString());
assertSegment(uniqueId.getSegments().get(0), "aType", "aValue");
}

@Test
void rootSegmentCanBeRetrieved() {
UniqueId uniqueId = UniqueId.root("aType", "aValue");

assertEquals(new Segment("aType", "aValue"), uniqueId.getRoot().get());
}

@Test
void appendingOneSegment() {
UniqueId engineId = UniqueId.root("engine", ENGINE_ID);
Expand All @@ -46,7 +74,7 @@ void appendingOneSegment() {
}

@Test
void appendingSegmentLeavesOriginialUnchanged() {
void appendingSegmentLeavesOriginalUnchanged() {
UniqueId uniqueId = UniqueId.root("engine", ENGINE_ID);
uniqueId.append("class", "org.junit.MyClass");

Expand Down

0 comments on commit 289b85a

Please sign in to comment.