Skip to content
Open
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 @@ -14,26 +14,6 @@

class StringRepresentationTypeHandlerTest {

/**
* Records whether {@link #getFromString} was reached. The contract under test is not just
* "returns empty" but "never forwards null to the subclass" — asserting only on the returned
* Optional would still pass if a subclass happened to tolerate null and return null itself.
*/
private static final class RecordingHandler extends StringRepresentationTypeHandler<String> {
private boolean getFromStringCalled;

@Override
public String getAsString(String item) {
return item;
}

@Override
public String getFromString(String representation) {
getFromStringCalled = true;
return representation;
}
}

private final RecordingHandler typeHandler = new RecordingHandler();

@Test
Expand Down Expand Up @@ -63,4 +43,24 @@ void ignoresNonStringData() {
assertFalse(result.isPresent());
assertFalse(typeHandler.getFromStringCalled);
}

/**
* Records whether {@link #getFromString} was reached. The contract under test is not just
* "returns empty" but "never forwards null to the subclass" — asserting only on the returned
* Optional would still pass if a subclass happened to tolerate null and return null itself.
*/
private static final class RecordingHandler extends StringRepresentationTypeHandler<String> {
private boolean getFromStringCalled;

@Override
public String getAsString(String item) {
return item;
}

@Override
public String getFromString(String representation) {
getFromStringCalled = true;
return representation;
}
}
}
Loading