@Test public void testMissingLocationReference() { LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder() .build(); try { geoCoordinatesDecoder.decode("1", locationReferenceData); fail(); } catch (PhysicalFormatException e) { assertEquals(e.getErrorCode(), OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } }
@Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasGeoCoordinatesLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference(); if (!geoCoordinatesLocationReference.hasCoordinates()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates(); GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); return new RawGeoCoordLocRef(id, geoCoordinates); }
GeoCoordinatesDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasGeoCoordinatesLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference(); if (!geoCoordinatesLocationReference.hasCoordinates()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates(); GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); return new RawGeoCoordLocRef(id, geoCoordinates); } }
GeoCoordinatesDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasGeoCoordinatesLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference(); if (!geoCoordinatesLocationReference.hasCoordinates()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates(); GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); return new RawGeoCoordLocRef(id, geoCoordinates); }  }
GeoCoordinatesDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasGeoCoordinatesLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference(); if (!geoCoordinatesLocationReference.hasCoordinates()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates(); GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); return new RawGeoCoordLocRef(id, geoCoordinates); }  @Override RawLocationReference decode(String id, LocationReferenceData data); }
GeoCoordinatesDecoder implements LocationReferenceDecoder { @Override public RawLocationReference decode(String id, LocationReferenceData data) throws OpenLRProtoException { if (!data.hasGeoCoordinatesLocationReference()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.MISSING_LOCATION_REFERENCE); } GeoCoordinatesLocationReference geoCoordinatesLocationReference = data.getGeoCoordinatesLocationReference(); if (!geoCoordinatesLocationReference.hasCoordinates()) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_LOCATION_REFERENCE); } Coordinates coordinates = geoCoordinatesLocationReference.getCoordinates(); GeoCoordinatesProtoImpl geoCoordinates = new GeoCoordinatesProtoImpl(coordinates.getLongitude(), coordinates.getLatitude()); return new RawGeoCoordLocRef(id, geoCoordinates); }  @Override RawLocationReference decode(String id, LocationReferenceData data);  }