Commit 55f4971f authored by Matija Obreza's avatar Matija Obreza

Make tests work

parent 8d0c9ee2
......@@ -18,6 +18,11 @@ package org.genesys2.spring.config;
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.elasticsearch.client.Client;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -26,11 +31,6 @@ import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.EntityMapper;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@EnableElasticsearchRepositories
@Configuration
@Import({ ElasticsearchConfigDev.class, ElasticsearchConfigAWS.class })
......
......@@ -16,14 +16,8 @@
package org.genesys2.server.test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
......@@ -31,6 +25,9 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.VelocityException;
......@@ -68,15 +65,13 @@ import org.genesys2.server.service.impl.TaxonomyServiceImpl;
import org.genesys2.server.service.impl.UserServiceImpl;
import org.genesys2.server.servlet.controller.rest.model.AccessionHeaderJson;
import org.genesys2.spring.config.HazelcastConfig;
import org.genesys2.tests.unit.FooBar;
import org.genesys2.spring.config.SpringCacheConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
......@@ -86,13 +81,10 @@ import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.ui.velocity.VelocityEngineFactoryBean;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("dev")
@ContextHierarchy({
@ContextConfiguration(name = "root", classes = { FooBar.class, JpaDataConfig.class, HazelcastConfig.class }, initializers = PropertyPlacholderInitializer.class),
@ContextConfiguration(name = "root", classes = { JpaDataConfig.class, HazelcastConfig.class, SpringCacheConfig.class }, initializers = PropertyPlacholderInitializer.class),
@ContextConfiguration(classes = BatchRESTServiceTest.Config.class, initializers = PropertyPlacholderInitializer.class)
})
@Ignore
......@@ -136,11 +128,6 @@ public class BatchRESTServiceTest {
return new GenesysServiceImpl();
}
@Bean
public CacheManager cacheManager() {
return new NoOpCacheManager();
}
@Bean
public HtmlSanitizer htmlSanitizer() {
return new OWASPSanitizer();
......
......@@ -2,8 +2,9 @@ package org.genesys2.tests.resttests;
import org.genesys2.server.test.JpaDataConfig;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.spring.config.ElasticsearchConfig;
import org.genesys2.spring.config.HazelcastConfig;
import org.genesys2.tests.unit.FooBar;
import org.genesys2.spring.config.SpringCacheConfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
......@@ -12,7 +13,7 @@ import org.springframework.test.context.TestPropertySource;
@Configuration
@TestPropertySource({ "classpath:application.properties", "classpath:spring/spring.properties" })
@ActiveProfiles("dev")
@ContextConfiguration(name = "root", classes = { FooBar.class, JpaDataConfig.class, HazelcastConfig.class }, initializers = PropertyPlacholderInitializer.class)
@ContextConfiguration(name = "root", classes = { JpaDataConfig.class, HazelcastConfig.class, ElasticsearchConfig.class, SpringCacheConfig.class }, initializers = PropertyPlacholderInitializer.class)
public abstract class SpringTest {
......
......@@ -15,6 +15,8 @@
**/
package org.genesys2.tests.unit;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.velocity.app.VelocityEngine;
import org.genesys2.server.aspect.AsAdminAspect;
import org.genesys2.server.persistence.domain.ActivityPostRepository;
......@@ -38,6 +40,8 @@ import org.genesys2.server.service.CropService;
import org.genesys2.server.service.DescriptorService;
import org.genesys2.server.service.EMailService;
import org.genesys2.server.service.EMailVerificationService;
import org.genesys2.server.service.ElasticSearchManagementService;
import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoService;
......@@ -59,6 +63,9 @@ import org.genesys2.server.service.impl.CropServiceImpl;
import org.genesys2.server.service.impl.DescriptorServiceImpl;
import org.genesys2.server.service.impl.EMailServiceImpl;
import org.genesys2.server.service.impl.EMailVerificationServiceImpl;
import org.genesys2.server.service.impl.ElasticSearchManagementServiceImpl;
import org.genesys2.server.service.impl.ElasticsearchSearchServiceImpl;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.GenesysFilterServiceImpl;
import org.genesys2.server.service.impl.GenesysServiceImpl;
import org.genesys2.server.service.impl.GeoServiceImpl;
......@@ -72,6 +79,7 @@ import org.genesys2.server.service.impl.TeamServiceImpl;
import org.genesys2.server.service.impl.TokenVerificationServiceImpl;
import org.genesys2.server.service.impl.TraitServiceImpl;
import org.genesys2.server.service.impl.UserServiceImpl;
import org.genesys2.server.service.worker.ElasticUpdater;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.tests.resttests.SpringTest;
import org.junit.runner.RunWith;
......@@ -237,6 +245,31 @@ public abstract class AbstractServicesTest extends SpringTest {
public PasswordPolicy passwordPolicy() {
return new SimplePasswordPolicy();
}
@Bean
public ElasticService searchService() {
return new ElasticsearchSearchServiceImpl();
}
@Bean
public ElasticSearchManagementService elasticSearchManagementService() {
return new ElasticSearchManagementServiceImpl();
}
@Bean
public ElasticUpdater elasticUpdater() {
return new ElasticUpdater();
}
@Bean
public FilterHandler filterHandler() {
return new FilterHandler();
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
}
@Autowired
......
package org.genesys2.tests.unit;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.NoOpCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FooBar {
@Bean
public CacheManager cacheManager() {
return new NoOpCacheManager();
}
}
......@@ -81,6 +81,9 @@ mail.debug.message= Email has been sent succesfully\n\
hazelcast.instanceName=hz-genesys
hazelcast.name=genesys-hz-3.5
hazelcast.password=hazelcasts
# Binding and public address
hazelcast.publicAddress=
hazelcast.interfaces=
hazelcast.port=5701
# AWS Autodetection
......
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