@Test public void testUnsupportedLocationType() { LocationReferenceData locationReferenceData = LocationReferenceData.newBuilder() .build(); LocationReference locationReference = new LocationReferenceProtoImpl("1", LocationType.UNKNOWN, locationReferenceData); try { decoder.decodeData(locationReference); fail(); } catch (PhysicalFormatException e) { assertEquals(e.getErrorCode(), OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } }
@Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); } }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  @Override Class<?> getDataClass(); @Override RawLocationReference decodeData(LocationReference data); @Override String getDataFormatIdentifier(); }
OpenLRProtoDecoder implements PhysicalDecoder { @Override public RawLocationReference decodeData(LocationReference data) throws PhysicalFormatException { LocationType locationType = data.getLocationType(); LocationReferenceDecoder locationReferenceDecoder = locationTypeDecoderRegistry.getDecoder(locationType); if (locationReferenceDecoder == null) { throw new OpenLRProtoException(OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE); } Object locationReferenceData = data.getLocationReferenceData(); if (!(locationReferenceData instanceof LocationReferenceData)) { throw new OpenLRProtoException(OpenLRProtoStatusCode.INVALID_DATA_TYPE); } return locationReferenceDecoder.decode(data.getID(), (LocationReferenceData) locationReferenceData); }  @Override Class<?> getDataClass(); @Override RawLocationReference decodeData(LocationReference data); @Override String getDataFormatIdentifier();  }