Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
54fbae51
Commit
54fbae51
authored
Apr 13, 2015
by
Matija Obreza
Browse files
Make tests execute
parent
3c3ae9e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/genesys2/server/service/impl/KPIEntitiesTest.java
View file @
54fbae51
...
...
@@ -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
);
...
...
src/test/java/org/genesys2/server/service/impl/KPIServiceTest.java
View file @
54fbae51
...
...
@@ -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.Jpa
Real
DataConfig
;
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
(
Jpa
DataConfig
.
class
)
@Import
(
{
HazelcastConfig
.
class
,
JpaReal
DataConfig
.
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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment