Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class BasicTag implements Tag {
* implementations will likely vary the hashCode/equals causing ids that should
* be equivalent to not match as expected.
*/
static BasicTag convert(Tag t) {
public static BasicTag convert(Tag t) {
return (t instanceof BasicTag) ? (BasicTag) t : new BasicTag(t.key(), t.value());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,22 @@ public void testNullValue() {
NullPointerException.class, () -> new BasicTag("k", null));
Assertions.assertEquals("parameter 'value' cannot be null (key=k)", e.getMessage());
}

@Test
public void convertBasicTagReturnsSameInstance() {
BasicTag tag = new BasicTag("k", "v");
Assertions.assertSame(tag, BasicTag.convert(tag));
}

@Test
public void convertNonBasicTag() {
Tag tag = new Tag() {
@Override public String key() { return "k"; }
@Override public String value() { return "v"; }
};
BasicTag result = BasicTag.convert(tag);
Assertions.assertEquals("k", result.key());
Assertions.assertEquals("v", result.value());
Assertions.assertEquals(new BasicTag("k", "v"), result);
}
}