OpenLREncoder implements openlr.OpenLREncoder { @Override public List<LocationReferenceHolder> encodeLocations( final OpenLREncoderParameter parameter, final List<Location> loc) throws OpenLRProcessingException { if (loc == null || loc.isEmpty()) { LOG.error("No location provided!"); throw new OpenLREncoderProcessingException( EncoderProcessingError.INVALID_PARAMETER); } if (LOG.isDebugEnabled()) { LOG.debug("OpenLR encoding of " + loc.size() + " locations started"); } List<LocationReferenceHolder> llr = new ArrayList<LocationReferenceHolder>(); OpenLREncoderProperties properties = new OpenLREncoderProperties(parameter.getConfiguration(), parameter.getPhysicalEncoders()); for (Location l : loc) { LocationReferenceHolder lr = encodeLocation(parameter, properties, l); llr.add(lr); } return llr; }  static List<PhysicalEncoder> getPhysicalEncoderServices(); @Override List<LocationReferenceHolder> encodeLocations(
            final OpenLREncoderParameter parameter, final List<Location> loc); @Override LocationReferenceHolder encodeLocation(
            final OpenLREncoderParameter parameter, final Location loc); @Override String getMajorVersion(); @Override String getMinorVersion(); @Override String getPatchVersion(); @Override String getVersion();  }
@Test public final void testnotConnectedLocation() { List<LocationReferenceHolder> locationRef = null; try { OpenLREncoder encoder = new OpenLREncoder(); OpenLREncoderParameter params = new OpenLREncoderParameter.Builder().with(td.getMapDatabase()).with(td.getConfiguration()).buildParameter(); locationRef = encoder.encodeLocations(params, Arrays.asList(td.getNotConnectedLocation())); assertFalse(locationRef.get(0).isValid()); } catch (OpenLRProcessingException e) { fail("Encoding location failed with exception: " + e.getErrorCode(), e); } }
@Test public final void testLocationWithNullLines() { Location locNullLines = LocationFactory.createLineLocation( "locWithNullLines", Arrays.asList((Line) null, null)); Location locOneNullLine = LocationFactory.createLineLocation( "locWithOnlyOneNullLine", Arrays.asList((Line) null)); List<LocationReferenceHolder> encLocRef; try { OpenLREncoder encoder = new OpenLREncoder(); OpenLREncoderParameter params = new OpenLREncoderParameter.Builder().with(td.getMapDatabase()).with(td.getConfiguration()).buildParameter(); encLocRef = encoder.encodeLocations(params, Arrays.asList(locNullLines, locOneNullLine)); for (LocationReferenceHolder lrh : encLocRef) { assertFalse(lrh.isValid()); assertEquals(lrh.getReturnCode(), EncoderReturnCode.LOCATION_NOT_CONNECTED); } } catch (OpenLRProcessingException e) { fail("Encoding location failed with exception: " + e.getErrorCode(), e); } }