@Ignore @Test @Category(UnitTest.class) public void testReload() throws IOException { MrsPyramidMetadata meta = reader.read(); final ByteArrayOutputStream orig = new ByteArrayOutputStream(); meta.save(orig); String originalMetadata = orig.toString(); meta.setClassification(Classification.Categorical); meta.setMaxZoomLevel(100); meta.setTilesize(100); Assert.assertEquals("Classification wasn't overwritten correctly", Classification.Categorical, meta.getClassification()); Assert.assertEquals("Max zoom wasn't overwritten correctly", 100, meta.getMaxZoomLevel()); Assert.assertEquals("Tile size wasn't overwritten correctly", 100, meta.getTilesize()); reader.reload(); Assert.assertEquals("Classification wasn't reloaded correctly", Classification.Continuous, meta.getClassification()); Assert.assertEquals("Max zoom wasn't reloaded correctly", 10, meta.getMaxZoomLevel()); Assert.assertEquals("Tile size wasn't reloaded correctly", MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT_INT, meta.getTilesize()); final ByteArrayOutputStream os = new ByteArrayOutputStream(); meta.save(os); Assert.assertEquals("JSON dumps are different!", originalMetadata, os.toString()); }
@Override @SuppressWarnings("squid:S1166") public MrsPyramidMetadata reload() throws IOException { if (metadata == null) { return read(); } if (dataProvider == null) { throw new IOException("DataProvider not set!"); } String name = dataProvider.getResourceName(); if (name == null || name.length() == 0) { throw new IOException("Can not load metadata, resource name is empty!"); } MrsPyramidMetadata copy = loadMetadata(); Set<Method> getters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"), ReflectionUtils.withParametersCount(0))); Set<Method> setters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("set"), ReflectionUtils.withParametersCount(1))); for (Method getter : getters) { String gettername = getter.getName(); String settername = gettername.replaceFirst("get", "set"); for (Method setter : setters) { if (setter.getName().equals(settername)) { try { setter.invoke(metadata, getter.invoke(copy, new Object[]{})); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { } break; } } } return metadata; }
AccumuloMrsPyramidMetadataReader implements MrsPyramidMetadataReader { @Override @SuppressWarnings("squid:S1166") public MrsPyramidMetadata reload() throws IOException { if (metadata == null) { return read(); } if (dataProvider == null) { throw new IOException("DataProvider not set!"); } String name = dataProvider.getResourceName(); if (name == null || name.length() == 0) { throw new IOException("Can not load metadata, resource name is empty!"); } MrsPyramidMetadata copy = loadMetadata(); Set<Method> getters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"), ReflectionUtils.withParametersCount(0))); Set<Method> setters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("set"), ReflectionUtils.withParametersCount(1))); for (Method getter : getters) { String gettername = getter.getName(); String settername = gettername.replaceFirst("get", "set"); for (Method setter : setters) { if (setter.getName().equals(settername)) { try { setter.invoke(metadata, getter.invoke(copy, new Object[]{})); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { } break; } } } return metadata; } }
AccumuloMrsPyramidMetadataReader implements MrsPyramidMetadataReader { @Override @SuppressWarnings("squid:S1166") public MrsPyramidMetadata reload() throws IOException { if (metadata == null) { return read(); } if (dataProvider == null) { throw new IOException("DataProvider not set!"); } String name = dataProvider.getResourceName(); if (name == null || name.length() == 0) { throw new IOException("Can not load metadata, resource name is empty!"); } MrsPyramidMetadata copy = loadMetadata(); Set<Method> getters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"), ReflectionUtils.withParametersCount(0))); Set<Method> setters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("set"), ReflectionUtils.withParametersCount(1))); for (Method getter : getters) { String gettername = getter.getName(); String settername = gettername.replaceFirst("get", "set"); for (Method setter : setters) { if (setter.getName().equals(settername)) { try { setter.invoke(metadata, getter.invoke(copy, new Object[]{})); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { } break; } } } return metadata; } AccumuloMrsPyramidMetadataReader(AccumuloMrsImageDataProvider dataProvider,
    MrsPyramidMetadataReaderContext context);  AccumuloMrsPyramidMetadataReader(String name); }
AccumuloMrsPyramidMetadataReader implements MrsPyramidMetadataReader { @Override @SuppressWarnings("squid:S1166") public MrsPyramidMetadata reload() throws IOException { if (metadata == null) { return read(); } if (dataProvider == null) { throw new IOException("DataProvider not set!"); } String name = dataProvider.getResourceName(); if (name == null || name.length() == 0) { throw new IOException("Can not load metadata, resource name is empty!"); } MrsPyramidMetadata copy = loadMetadata(); Set<Method> getters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"), ReflectionUtils.withParametersCount(0))); Set<Method> setters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("set"), ReflectionUtils.withParametersCount(1))); for (Method getter : getters) { String gettername = getter.getName(); String settername = gettername.replaceFirst("get", "set"); for (Method setter : setters) { if (setter.getName().equals(settername)) { try { setter.invoke(metadata, getter.invoke(copy, new Object[]{})); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { } break; } } } return metadata; } AccumuloMrsPyramidMetadataReader(AccumuloMrsImageDataProvider dataProvider,
    MrsPyramidMetadataReaderContext context);  AccumuloMrsPyramidMetadataReader(String name); void reset(MrsPyramidMetadata m); @Override MrsPyramidMetadata read(); @Override @SuppressWarnings("squid:S1166") // Exception caught and handled MrsPyramidMetadata reload(); void setConnector(Connector conn); }
AccumuloMrsPyramidMetadataReader implements MrsPyramidMetadataReader { @Override @SuppressWarnings("squid:S1166") public MrsPyramidMetadata reload() throws IOException { if (metadata == null) { return read(); } if (dataProvider == null) { throw new IOException("DataProvider not set!"); } String name = dataProvider.getResourceName(); if (name == null || name.length() == 0) { throw new IOException("Can not load metadata, resource name is empty!"); } MrsPyramidMetadata copy = loadMetadata(); Set<Method> getters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"), ReflectionUtils.withParametersCount(0))); Set<Method> setters = ReflectionUtils.getAllMethods(MrsPyramidMetadata.class, Predicates.<Method>and( Predicates.<AnnotatedElement>not(ReflectionUtils.withAnnotation(JsonIgnore.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("set"), ReflectionUtils.withParametersCount(1))); for (Method getter : getters) { String gettername = getter.getName(); String settername = gettername.replaceFirst("get", "set"); for (Method setter : setters) { if (setter.getName().equals(settername)) { try { setter.invoke(metadata, getter.invoke(copy, new Object[]{})); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) { } break; } } } return metadata; } AccumuloMrsPyramidMetadataReader(AccumuloMrsImageDataProvider dataProvider,
    MrsPyramidMetadataReaderContext context);  AccumuloMrsPyramidMetadataReader(String name); void reset(MrsPyramidMetadata m); @Override MrsPyramidMetadata read(); @Override @SuppressWarnings("squid:S1166") // Exception caught and handled MrsPyramidMetadata reload(); void setConnector(Connector conn);  }