Add toString method to AbstractInstrument (#4883)
* Add toString method to AbstractInstrument * add test for toString method * use hasToString assertion for toString test
This commit is contained in:
parent
45717e414f
commit
5ac1cef1e8
|
|
@ -39,4 +39,9 @@ abstract class AbstractInstrument {
|
|||
public int hashCode() {
|
||||
return descriptor.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + "{" + "descriptor=" + getDescriptor() + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ class AbstractInstrumentTest {
|
|||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue