Location { public static Builder builder() { return new Builder(); } private  Location(final String path, final int line, final int column); private  Location(final Builder builder); static Location create(final String path, final int line); static Location create(final String path, final int line, final int column); String getPath(); int getLine(); int getColumn(); @Generated(value = "org.eclipse.Eclipse") @Override int hashCode(); @Generated(value = "org.eclipse.Eclipse") @Override boolean equals(final Object obj); @Override String toString(); static Builder builder(); static final int NO_LINE; static final int NO_COLUMN; }
@Test void testBuilder() { final String expectedPath = "expected"; final int expectedLine = 4007; final int expectedColumn = 10203; final Location location = Location.builder().path(expectedPath).line(expectedLine) .column(expectedColumn).build(); assertThat(location.getPath(), equalTo(expectedPath)); assertThat(location.getLine(), equalTo(expectedLine)); assertThat(location.getColumn(), equalTo(expectedColumn)); }
@Test void testIsComplete() { final Location.Builder builder = Location.builder().path("a"); assertThat("builder with path set to null is complete", builder.isCompleteEnough(), equalTo(true)); }
@Test void testIsNotCompleteEnoughWithoutPath() { final Location.Builder builderA = Location.builder().path(""); final Location.Builder builderB = Location.builder(); assertThat("builder with empty path is complete", builderA.isCompleteEnough(), equalTo(false)); assertThat("builder with path set to null is complete", builderB.isCompleteEnough(), equalTo(false)); }