Commit 881b5900 authored by LAVENIER's avatar LAVENIER
Browse files

[fix] Remove unused JsonMapperConfiguration

parent a414192b
package net.sumaris.server.http.json;
/*-
* #%L
* SUMARiS:: Server
* %%
* Copyright (C) 2018 SUMARiS Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import java.text.SimpleDateFormat;
//@Configuration
// TODO: can be removed
public class JsonMapperConfiguration {
@Bean
public ObjectMapper jacksonObjectMapper() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder()
.featuresToDisable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)
.featuresToEnable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
//.deserializerByType(Map.class, new LinkedHashMapDeserializer())
//.timeZone(TimeZone.getTimeZone(ZoneOffset.UTC))
;
// Add mixin here
// See https://blog.netapsys.fr/les-mixins-de-jackson-2-de-vrais-ameliorations-a-decouvrir/
//Map<Class<?>, Class<?>> mixins = new HashMap<>();
//builder.mixIns(mixins)
return builder.build();
}
}
package net.sumaris.server.http.json;
/*-
* #%L
* SUMARiS:: Server
* %%
* Copyright (C) 2018 - 2019 SUMARiS Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author Benoit Lavenier <benoit.lavenier@e-is.pro>*
*/
public class LinkedHashMapDeserializer extends JsonDeserializer<Object> {
@Override
public Object deserialize(JsonParser jp, DeserializationContext context)
throws IOException {
Map map = new LinkedHashMap();
ObjectCodec oc = jp.getCodec();
ObjectNode mapNode = oc.readTree(jp);
Iterator it = mapNode.elements();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
map.put(entry.getKey(), entry.getValue());
}
return map;
}
}
package net.sumaris.server.service;
/*-
/*
* #%L
* SUMARiS:: Server
* SUMARiS
* %%
* Copyright (C) 2018 SUMARiS Consortium
* Copyright (C) 2019 SUMARiS Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import net.sumaris.server.TestConfiguration;
package net.sumaris.server;
import net.sumaris.server.config.SumarisServerConfiguration;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,7 +32,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {TestConfiguration.class})
@SpringBootTest(classes = {ServiceTestConfiguration.class})
@TestPropertySource(locations="classpath:sumaris-server-test.properties")
public abstract class AbstractServiceTest {
......
......@@ -55,17 +55,17 @@ public class DatabaseResource extends net.sumaris.core.test.DatabaseResource {
@Override
public String getDatasourcePlatform() {
return TestConfiguration.DATASOURCE_PLATFORM;
return ServiceTestConfiguration.DATASOURCE_PLATFORM;
}
@Override
protected String getConfigFilesPrefix() {
return TestConfiguration.CONFIG_FILE_PREFIX;
return ServiceTestConfiguration.CONFIG_FILE_PREFIX;
}
@Override
protected String getModuleDirectory() {
return TestConfiguration.MODULE_NAME;
return ServiceTestConfiguration.MODULE_NAME;
}
}
......@@ -49,8 +49,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EntityScan("net.sumaris.core.model")
@EnableTransactionManagement
@EnableJpaRepositories("net.sumaris.core.dao")
@org.springframework.boot.test.context.TestConfiguration
public class TestConfiguration extends net.sumaris.core.test.TestConfiguration {
public class ServiceTestConfiguration extends net.sumaris.core.test.TestConfiguration {
public static final String MODULE_NAME = "sumaris-server";
public static final String DATASOURCE_PLATFORM = "hsqldb";
......
......@@ -25,26 +25,22 @@ package net.sumaris.server.http.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.sumaris.core.vo.data.TripVO;
import net.sumaris.server.AbstractServiceTest;
import org.geojson.Feature;
import org.geojson.FeatureCollection;
import org.geojson.Point;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.util.HashMap;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {JsonMapperConfiguration.class})
@TestPropertySource(locations="classpath:sumaris-server-test.properties")
public class JsonMapperTest {
public class JsonMapperTest extends AbstractServiceTest {
@Autowired
private ObjectMapper objectMapper;
......@@ -59,7 +55,7 @@ public class JsonMapperTest {
}
@Test
public void testGeoJsonSerialisation() throws JsonProcessingException, UnsupportedEncodingException, IOException {
public void testGeoJsonSerialisation() throws IOException {
FeatureCollection features = new FeatureCollection();
......
......@@ -21,7 +21,7 @@ spring.datasource.username=sa
spring.datasource.password=
#spring.datasource.url=@jdbc.url@
#spring.datasource.url=jdbc:hsqldb:hsql://localhost/sumaris
#spring.datasource.url=jdbc:hsqldb:file:target/db/sumaris
spring.datasource.url=jdbc:hsqldb:file:../sumaris-core/target/db/sumaris
spring.datasource.platform=hsqldb
spring.datasource.initialization-mode=always
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment