### Question:
Position implements Message, Serializable { public String getLongitudeAsString() { double lon = longitude; if (lon < 0) { lon *= -1; } int hours = (int) lon; lon -= hours; lon *= 60; StringBuilder longitudeAsString = new StringBuilder(16); longitudeAsString.append(format000(hours)); longitudeAsString.append(" "); longitudeAsString.append(format00((int) lon)); longitudeAsString.append("."); longitudeAsString.append(format000((int) Math.round(1000 * (lon - (int) lon)))); longitudeAsString.append(longitude < 0 ? "W" : "E"); return longitudeAsString.toString(); } Position(double latitude, double longitude); @Override boolean equals(Object other); boolean equals(Position other); double geodesicDistanceTo(Position other); double geodesicFinalBearingTo(Position other); double geodesicInitialBearingTo(Position other); long getCell(double degress); int getCellInt(double degress); double getLatitude(); String getLatitudeAsString(); double getLongitude(); String getLongitudeAsString(); @Override int hashCode(); @Override Position immutable(); double rhumbLineBearingTo(Position position); double rhumbLineDistanceTo(Position other); String toJSON(); long toPackedLong(); @Override String toString(); String toStringDegrees(); Position withLatitude(double latitude); Position withLongitude(double longitude); PositionTime withTime(long time); static Position create(double latitude, double longitude); static Position fromBinary(Binary b); Binary toBinary(); static Position fromPackedLong(long l); static boolean isValid(double latitude, double longitude); static Position random(); static Position random(Random rnd); static double verifyLatitude(double latitude); static double verifyLongitude(double longitude); static final MessageSerializer<Position> SERIALIZER; }### Answer:
@Test public void testGetLongitudeAsString() { assertEquals("000 00.000E", Position.create(0.0, 0.0).getLongitudeAsString()); assertEquals("180 00.000E", Position.create(0.0, 180.0).getLongitudeAsString()); assertEquals("180 00.000W", Position.create(0.0, -180.0).getLongitudeAsString()); assertEquals("001 00.000E", Position.create(0.0, 1.0).getLongitudeAsString()); assertEquals("001 00.000W", Position.create(0.0, -1.0).getLongitudeAsString()); assertEquals("011 34.046E", Position.create(0.0, 11.56743).getLongitudeAsString()); assertEquals("011 34.046W", Position.create(0.0, -11.56743).getLongitudeAsString()); assertEquals("005 00.000E", Position.create(0.0, 5.0).getLongitudeAsString()); assertEquals("005 33.600E", Position.create(0.0, 5.56).getLongitudeAsString()); assertEquals("005 33.650E", Position.create(0.0, 5.56083).getLongitudeAsString()); assertEquals("001 00.000E", Position.create(0.0, 1.0).getLongitudeAsString()); assertEquals("001 06.000E", Position.create(0.0, 1.1).getLongitudeAsString()); assertEquals("001 00.000E", Position.create(0.0, 1.0).getLongitudeAsString()); assertEquals("010 00.000E", Position.create(0.0, 10.0).getLongitudeAsString()); assertEquals("010 56.843E", Position.create(0.0, 10.94738243).getLongitudeAsString()); }