Skip to content

Commit

Permalink
Add toString method to AbstractInstrument (#4883)
Browse files Browse the repository at this point in the history
* Add toString method to AbstractInstrument

* add test for toString method

* use hasToString assertion for toString test
  • Loading branch information
mkorzeniewski committed Oct 25, 2022
1 parent 45717e4 commit 5ac1cef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -39,4 +39,9 @@ public boolean equals(@Nullable Object o) {
public int hashCode() {
return descriptor.hashCode();
}

@Override
public String toString() {
return this.getClass().getSimpleName() + "{" + "descriptor=" + getDescriptor() + '}';
}
}
Expand Up @@ -22,6 +22,13 @@ void getValues() {
assertThat(testInstrument.getDescriptor()).isSameAs(INSTRUMENT_DESCRIPTOR);
}

@Test
void testToString() {
TestInstrument testInstrument = new TestInstrument(INSTRUMENT_DESCRIPTOR);
assertThat(testInstrument)
.hasToString("TestInstrument{descriptor=" + INSTRUMENT_DESCRIPTOR + "}");
}

private static final class TestInstrument extends AbstractInstrument {
TestInstrument(InstrumentDescriptor descriptor) {
super(descriptor);
Expand Down

0 comments on commit 5ac1cef

Please sign in to comment.