Remove unused and unnecessary code.

This commit is contained in:
John Blum
2020-06-09 20:47:04 -07:00
parent f83880ea97
commit 53dda1265b
3 changed files with 1 additions and 55 deletions

View File

@@ -40,9 +40,7 @@ import org.springframework.geode.data.AbstractCacheDataImporterExporter;
import org.springframework.geode.data.CacheDataExporter;
import org.springframework.geode.data.CacheDataImporter;
import org.springframework.geode.data.json.converter.JsonToPdxArrayConverter;
import org.springframework.geode.data.json.converter.JsonToPdxConverter;
import org.springframework.geode.data.json.converter.ObjectToJsonConverter;
import org.springframework.geode.data.json.converter.support.JSONFormatterJsonToPdxConverter;
import org.springframework.geode.data.json.converter.support.JSONFormatterPdxToJsonConverter;
import org.springframework.geode.data.json.converter.support.JacksonJsonToPdxConverter;
import org.springframework.geode.pdx.PdxInstanceWrapper;
@@ -58,6 +56,7 @@ import org.springframework.util.StringUtils;
* implementation that can export/import JSON data to/from a {@link Resource} given a target {@link Region}.
*
* @author John Blum
* @see java.io.File
* @see org.apache.geode.cache.Region
* @see org.apache.geode.pdx.PdxInstance
* @see org.springframework.core.io.ClassPathResource
@@ -67,9 +66,7 @@ import org.springframework.util.StringUtils;
* @see org.springframework.geode.data.CacheDataExporter
* @see org.springframework.geode.data.CacheDataImporter
* @see org.springframework.geode.data.json.converter.JsonToPdxArrayConverter
* @see org.springframework.geode.data.json.converter.JsonToPdxConverter
* @see org.springframework.geode.data.json.converter.ObjectToJsonConverter
* @see org.springframework.geode.data.json.converter.support.JSONFormatterJsonToPdxConverter
* @see org.springframework.geode.data.json.converter.support.JSONFormatterPdxToJsonConverter
* @see org.springframework.geode.data.json.converter.support.JacksonJsonToPdxConverter
* @see org.springframework.geode.pdx.PdxInstanceWrapper
@@ -96,17 +93,10 @@ public class JsonCacheDataImporterExporter extends AbstractCacheDataImporterExpo
protected static final String NO_FIELD_NAME = "";
protected static final String RESOURCE_NAME_PATTERN = "data-%s.json";
private JsonToPdxConverter jsonToPdxConverter = newJsonToPdxConverter();
private JsonToPdxArrayConverter jsonToPdxArrayConverter = newJsonToPdxArrayConverter();
private ObjectToJsonConverter objectToJsonConverter = newObjectToJsonConverter();
// TODO configure via an SPI
private @NonNull JsonToPdxConverter newJsonToPdxConverter() {
return new JSONFormatterJsonToPdxConverter();
}
// TODO configure via an SPI
private @NonNull JsonToPdxArrayConverter newJsonToPdxArrayConverter() {
return new JacksonJsonToPdxConverter();
@@ -117,16 +107,6 @@ public class JsonCacheDataImporterExporter extends AbstractCacheDataImporterExpo
return new JSONFormatterPdxToJsonConverter();
}
/**
* Gets a reference to the configured {@link JsonToPdxConverter}.
*
* @return a reference to the configured {@link JsonToPdxConverter}.
* @see org.springframework.geode.data.json.converter.JsonToPdxConverter
*/
protected @NonNull JsonToPdxConverter getJsonToPdxConverter() {
return this.jsonToPdxConverter;
}
/**
* Returns a reference to the configured {@link JsonToPdxArrayConverter}.
*
@@ -454,18 +434,6 @@ public class JsonCacheDataImporterExporter extends AbstractCacheDataImporterExpo
return getObjectToJsonConverter().convert(source);
}
/**
* Converts the given JSON object into a {@link PdxInstance}.
*
* @param json array of {@link Byte#TYPE bytes} containing JSON.
* @return a {@link PdxInstance} converted from the JSON object.
* @see org.apache.geode.pdx.PdxInstance
* @see #getJsonToPdxConverter()
*/
protected @NonNull PdxInstance toPdx(@NonNull byte[] json) {
return getJsonToPdxConverter().convert(json);
}
/**
* Converts the array of {@link Byte#TYPE bytes} containing multiple JSON objects
* into an array of {@link PdxInstance PdxInstances}.

View File

@@ -86,8 +86,6 @@ public class JSONFormatterPdxToJsonConverter extends JacksonObjectToJsonConverte
* @see #jsonFormatterToJson(PdxInstance)
*/
protected @NonNull String convertPdxToJson(@NonNull PdxInstance pdxInstance) {
//return jsonFormatterToJson(pdxInstance);
//return jsonFormatterToJson(decorate(pdxInstance));
return decorate(pdxInstance, jsonFormatterToJson(pdxInstance));
}

View File

@@ -55,7 +55,6 @@ import org.springframework.core.io.Resource;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.data.gemfire.util.ArrayUtils;
import org.springframework.geode.data.json.converter.JsonToPdxArrayConverter;
import org.springframework.geode.data.json.converter.JsonToPdxConverter;
import org.springframework.geode.data.json.converter.ObjectToJsonConverter;
import example.app.crm.model.Customer;
@@ -75,7 +74,6 @@ import example.app.pos.model.LineItem;
* @see org.springframework.core.io.Resource
* @see org.springframework.geode.data.json.JsonCacheDataImporterExporter
* @see org.springframework.geode.data.json.converter.JsonToPdxArrayConverter
* @see org.springframework.geode.data.json.converter.JsonToPdxConverter
* @see org.springframework.geode.data.json.converter.ObjectToJsonConverter
* @since 1.3.0
*/
@@ -899,24 +897,6 @@ public class JsonCacheDataImporterExporterUnitTests {
verify(mockConverter, times(1)).convert(eq("TEST"));
}
@Test
public void toPdxFromJsonCallsJsonToPdxConverter() {
byte[] json = "{ \"name\": \"Jon Doe\" }".getBytes();
JsonToPdxConverter mockConverter = mock(JsonToPdxConverter.class);
PdxInstance mockPdxInstance = mock(PdxInstance.class);
doReturn(mockConverter).when(this.importer).getJsonToPdxConverter();
doReturn(mockPdxInstance).when(mockConverter).convert(eq(json));
assertThat(this.importer.toPdx(json)).isEqualTo(mockPdxInstance);
verify(this.importer, times(1)).getJsonToPdxConverter();
verify(mockConverter, times(1)).convert(eq(json));
}
@Test
public void toPdxArrayFromJsonCallsJsonToPdxArrayConverter() {