LocationKlvProcessor implements KlvProcessor { @Override public void process( Map<String, KlvHandler> handlers, Metacard metacard, Configuration configuration) { if (configuration.get(Configuration.SUBSAMPLE_COUNT) == null || (Integer) configuration.get(Configuration.SUBSAMPLE_COUNT) < MIN_SUBSAMPLE_COUNT) { LOGGER.debug( "the subsample count configuration is missing or incorrectly configured (the minimum subsample count is {}), skipping location klv processing", MIN_SUBSAMPLE_COUNT); return; } Integer subsampleCount = (Integer) configuration.get(Configuration.SUBSAMPLE_COUNT); tryCornerData(handlers, metacard, subsampleCount, configuration.getGeometryOperatorContext()); if (isLocationNotSet(metacard)) { tryFrameCenterData( handlers, metacard, subsampleCount, configuration.getGeometryOperatorContext()); } } LocationKlvProcessor();  LocationKlvProcessor(
      GeometryOperator preUnionGeometryOperator, GeometryOperator postUnionGeometryOperator); GeometryOperator getGeometryFunction(); @Override void process(
      Map<String, KlvHandler> handlers, Metacard metacard, Configuration configuration); @Override void accept(Visitor visitor); static final Integer MIN_SUBSAMPLE_COUNT; }
@Test public void testMissingHandlers() { klvConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, 50); locationKlvProcessor.process(Collections.emptyMap(), metacard, klvConfiguration); assertThat(metacard.getLocation(), nullValue()); }
@Test public void testProcessCorner() { klvConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, 50); locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), is(wkt)); }
@Test public void testProcessFrameCenter() { klvConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, 50); Attribute attribute = mock(Attribute.class); when(attribute.getValues()).thenReturn(Collections.emptyList()); when(geoBoxHandler.asAttribute()).thenReturn(Optional.of(attribute)); when(geoBoxHandler.getAttributeName()).thenReturn(AttributeNameConstants.CORNER); attribute = mock(Attribute.class); when(attribute.getValues()) .thenReturn(Arrays.asList("POINT(0 0)", "POINT(5 5)", "POINT(10 10)")); when(latLonHandler.asAttribute()).thenReturn(Optional.of(attribute)); when(latLonHandler.getAttributeName()).thenReturn(AttributeNameConstants.FRAME_CENTER); locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), is(wktLineString)); }
@Test public void testMissingConfiguration() { locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), nullValue()); }
@Test public void testBadConfiguration() { klvConfiguration.set( KlvProcessor.Configuration.SUBSAMPLE_COUNT, LocationKlvProcessor.MIN_SUBSAMPLE_COUNT - 1); locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), nullValue()); }