Skip to content

Commit

Permalink
Object mapper for spatial serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dhlevi committed Nov 25, 2024
1 parent d44952f commit a14085d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import org.springframework.core.Ordered;
import org.springframework.web.filter.ForwardedHeaderFilter;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.vividsolutions.jts.geom.Geometry;

import ca.bc.gov.nrs.wfprev.common.serializers.GeoJsonJacksonDeserializer;
import ca.bc.gov.nrs.wfprev.common.serializers.GeoJsonJacksonSerializer;
import jakarta.servlet.DispatcherType;

@SpringBootApplication
Expand Down Expand Up @@ -45,4 +52,14 @@ public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registration;
}

@Bean
public ObjectMapper registerObjectMapper(){
ObjectMapper mapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(new GeoJsonJacksonSerializer());
simpleModule.addDeserializer(Geometry.class, new GeoJsonJacksonDeserializer());
mapper.registerModule(simpleModule);
return mapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.nimbusds.jose.shaded.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

@TestConfiguration(proxyBeanMethods = false)
class TestcontainersConfiguration {

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgresContainer() {
Expand All @@ -31,5 +30,4 @@ PostgreSQLContainer<?> postgresContainer() {

return container;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring.liquibase.change-log=classpath:db/main-changelog.xml
spring.liquibase.drop-first=true
spring.liquibase.contexts=test

0 comments on commit a14085d

Please sign in to comment.