Commit 54fbae51 authored by Matija Obreza's avatar Matija Obreza
Browse files

Make tests execute

parent 3c3ae9e1
......@@ -42,25 +42,35 @@ import org.genesys2.server.persistence.domain.kpi.DimensionKeyRepository;
import org.genesys2.server.service.KPIService;
import org.genesys2.server.test.JpaDataConfig;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.spring.config.HazelcastConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = KPIEntitiesTest.Config.class, initializers = PropertyPlacholderInitializer.class)
@ActiveProfiles("dev")
public class KPIEntitiesTest {
private static Logger log = Logger.getLogger(KPIEntitiesTest.class);
@Import(JpaDataConfig.class)
// @ComponentScan(basePackages = { "org.genesys2.server.persistence.domain"
// })
@Import({ HazelcastConfig.class, JpaDataConfig.class })
public static class Config {
@Bean
public HazelcastCacheManager cacheManager(HazelcastInstance hazelcastInstance) {
HazelcastCacheManager cm = new HazelcastCacheManager(hazelcastInstance);
return cm;
}
@Bean
public KPIService kpiService() {
return new KPIServiceImpl();
......@@ -136,7 +146,7 @@ public class KPIEntitiesTest {
assertTrue(dim.hasFalse());
assertTrue(dim.hasTrue());
log.debug(dim.getValues());
dim.useFalse(false);
assertFalse(dim.hasFalse());
assertTrue(dim.hasTrue());
......@@ -146,16 +156,16 @@ public class KPIEntitiesTest {
dim.setMode(3);
assertTrue(dim.hasTrue());
assertTrue(dim.hasFalse());
Dimension<?> savedDim = kpiService.save(dim);
assertTrue(savedDim == dim);
assertTrue(savedDim.getId() != null);
// For comparison
Set<Boolean> list = new HashSet<Boolean>();
list.add(true);
list.add(false);
Dimension<?> loaded = kpiService.getDimension(savedDim.getId());
assertTrue(loaded != savedDim);
assertTrue(StringUtils.equals(loaded.getName(), dim.getName()));
......@@ -265,8 +275,7 @@ public class KPIEntitiesTest {
log.info("Query = " + paQuery);
kpiService.save(execution);
Execution execution2 = new Execution();
execution2.setName("versionexec");
execution2.setParameter(parameter);
......
......@@ -31,26 +31,38 @@ import org.genesys2.server.model.kpi.NumericListDimension;
import org.genesys2.server.model.kpi.Observation;
import org.genesys2.server.model.kpi.StringListDimension;
import org.genesys2.server.service.KPIService;
import org.genesys2.server.test.JpaDataConfig;
import org.genesys2.server.test.JpaRealDataConfig;
import org.genesys2.server.test.PropertyPlacholderInitializer;
import org.genesys2.spring.config.HazelcastConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = KPIServiceTest.Config.class, initializers = PropertyPlacholderInitializer.class)
@ActiveProfiles("dev")
public class KPIServiceTest {
private static Logger log = Logger.getLogger(KPIService.class);
@Import(JpaDataConfig.class)
@Import({ HazelcastConfig.class, JpaRealDataConfig.class })
@ComponentScan(basePackages = { "org.genesys2.server.persistence.domain" })
public static class Config {
@Bean
public HazelcastCacheManager cacheManager(HazelcastInstance hazelcastInstance) {
HazelcastCacheManager cm = new HazelcastCacheManager(hazelcastInstance);
return cm;
}
@Bean
public KPIService kpiService() {
return new KPIServiceImpl();
......@@ -72,7 +84,7 @@ public class KPIServiceTest {
printRes(res);
}
// @Test
@Test
public void test1() {
log.info("Test 1");
......@@ -116,10 +128,6 @@ public class KPIServiceTest {
log.info("Result is null");
}
public static void main(String[] a) {
new KPIServiceTest().test2();
}
@Test
public void test2() {
StringListDimension dimInstCode = new StringListDimension();
......
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