Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
d8bedcd9
Commit
d8bedcd9
authored
Jul 09, 2020
by
Piotr Gawron
Browse files
unit tests fixed
parent
d49c67a7
Pipeline
#29610
failed with stage
in 12 minutes and 58 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
web/src/test/java/lcsb/mapviewer/web/ChemicalControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -9,8 +9,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.mock.web.MockHttpSession
;
...
...
@@ -26,6 +25,7 @@ import com.google.gson.JsonParser;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.services.interfaces.IModelService
;
import
lcsb.mapviewer.services.interfaces.IProjectService
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
...
...
@@ -43,12 +43,20 @@ public class ChemicalControllerIntegrationTest extends ControllerIntegrationTest
@Autowired
private
IProjectService
projectService
;
@Autowired
private
IModelService
modelService
;
@Before
public
void
setup
()
{
assumeTrue
(
"DAPI credentials are not provided"
,
isDapiConfigurationAvailable
());
createProject
(
TEST_PROJECT
);
}
@After
public
void
tearDown
()
{
modelService
.
removeModelFromCacheByProjectId
(
TEST_PROJECT
);
}
@Test
public
void
testSearchChemicalsInProjectUrl
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
...
...
web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -56,7 +56,6 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
Logger
logger
=
LogManager
.
getLogger
();
private
static
final
String
TEST_PROJECT
=
"test_project"
;
private
static
final
String
TEST_USER_PASSWORD
=
"test_user_pass"
;
private
static
final
String
TEST_USER_LOGIN
=
"test_user"
;
private
static
final
String
TEST_CURATOR_PASSWORD
=
"test_curator_pass"
;
...
...
web/src/test/java/lcsb/mapviewer/web/ConfigurationControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -175,15 +175,19 @@ public class ConfigurationControllerIntegrationTest extends ControllerIntegratio
UserDto
user
=
new
UserDto
();
user
.
setLogin
(
"admin"
);
user
.
setPassword
(
"admin"
);
user
.
setLogin
(
"
minerva
@uni.lu"
);
user
.
setLogin
(
"
piotr.gawron
@uni.lu"
);
RequestBuilder
request
=
post
(
"/configuration/dapi:registerUser"
)
.
content
(
new
ObjectMapper
().
writeValueAsString
(
user
))
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isConflict
());
try
{
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isConflict
());
}
catch
(
Exception
e
)
{
System
.
exit
(
0
);
throw
e
;
}
}
private
ResponseFieldsSnippet
configurationFields
()
{
...
...
web/src/test/java/lcsb/mapviewer/web/ControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -59,6 +59,7 @@ import lcsb.mapviewer.persist.dao.ProjectDao;
import
lcsb.mapviewer.persist.dao.cache.UploadedFileEntryDao
;
import
lcsb.mapviewer.persist.dao.map.*
;
import
lcsb.mapviewer.persist.dao.user.UserDao
;
import
lcsb.mapviewer.services.interfaces.IModelService
;
import
lcsb.mapviewer.services.interfaces.IUserService
;
import
lcsb.mapviewer.web.config.SpringWebConfig
;
...
...
@@ -76,6 +77,8 @@ abstract public class ControllerIntegrationTest {
protected
static
final
String
BUILT_IN_PROJECT
=
"empty"
;
protected
static
final
String
TEST_PROJECT
=
"test_project"
;
@Rule
public
UnitTestFailedWatcher
unitTestFailedWatcher
=
new
UnitTestFailedWatcher
();
protected
MockMvc
mockMvc
;
...
...
@@ -118,6 +121,9 @@ abstract public class ControllerIntegrationTest {
@Autowired
private
ChemicalRestImpl
chemicalRestImpl
;
@Autowired
private
IModelService
modelService
;
@PostConstruct
public
void
construct
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
context
)
...
...
@@ -137,7 +143,7 @@ abstract public class ControllerIntegrationTest {
}
@PreDestroy
public
void
tearDown
()
throws
Exception
{
public
final
void
__
tearDown
()
throws
Exception
{
executorService
.
shutdown
();
}
...
...
@@ -326,14 +332,13 @@ abstract public class ControllerIntegrationTest {
ModelSubmodelConnection
submodelConnection
=
new
ModelSubmodelConnection
(
submap
,
SubmodelType
.
UNKNOWN
);
map
.
addSubmodel
(
submodelConnection
);
project
.
addModel
(
map
);
projectDao
.
add
(
project
);
return
project
;
}
private
Element
createSimpleMolecule
()
{
Element
element2
=
new
SimpleMolecule
(
"s"
+
(
counter
++));
Element
element2
=
new
SimpleMolecule
(
"s"
+
(
counter
++));
element2
.
setName
(
"water"
);
element2
.
setWidth
(
100.0
);
element2
.
setHeight
(
20.0
);
...
...
@@ -349,7 +354,7 @@ abstract public class ControllerIntegrationTest {
int
counter
=
1
;
private
GenericProtein
createProtein
()
{
GenericProtein
element
=
new
GenericProtein
(
"s"
+
(
counter
++));
GenericProtein
element
=
new
GenericProtein
(
"s"
+
(
counter
++));
element
.
setName
(
"GSTA4"
);
element
.
setWidth
(
100.0
);
element
.
setHeight
(
20.0
);
...
...
@@ -478,6 +483,7 @@ abstract public class ControllerIntegrationTest {
if
(
project
!=
null
)
{
projectDao
.
delete
(
project
);
}
modelService
.
removeModelFromCacheByProjectId
(
projectId
);
return
null
;
});
}
...
...
web/src/test/java/lcsb/mapviewer/web/DrugControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -7,9 +7,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.mock.web.MockHttpSession
;
import
org.springframework.restdocs.payload.ResponseFieldsSnippet
;
import
org.springframework.test.annotation.Rollback
;
...
...
@@ -18,8 +18,7 @@ import org.springframework.test.web.servlet.RequestBuilder;
import
org.springframework.transaction.annotation.Transactional
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.user.ConfigurationElementType
;
import
lcsb.mapviewer.services.interfaces.IConfigurationService
;
import
lcsb.mapviewer.services.interfaces.IModelService
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Transactional
...
...
@@ -30,11 +29,19 @@ public class DrugControllerIntegrationTest extends ControllerIntegrationTest {
Logger
logger
=
LogManager
.
getLogger
();
@Autowired
private
IModelService
modelService
;
@Before
public
void
setup
()
{
createProject
(
TEST_PROJECT
);
}
@After
public
void
tearDown
()
{
modelService
.
removeModelFromCacheByProjectId
(
TEST_PROJECT
);
}
@Test
public
void
testSearchDrugsInProjectUrl
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
...
...
web/src/test/java/lcsb/mapviewer/web/FunctionControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -31,8 +31,6 @@ import lcsb.mapviewer.services.interfaces.IModelService;
@Rollback
public
class
FunctionControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Project
project
;
ModelData
map
;
...
...
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -47,8 +47,6 @@ import lcsb.mapviewer.services.interfaces.IUserService;
@Rollback
public
class
MapControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
@Autowired
...
...
@@ -200,6 +198,10 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.
description
(
"SBML kinetics initial concentration"
)
.
type
(
"boolean"
)
.
optional
(),
fieldWithPath
(
"[].glyph"
)
.
description
(
"image glyph associated with the element"
)
.
type
(
"Glyph"
)
.
optional
(),
subsectionWithPath
(
"[].other"
)
.
description
(
"list of oher properties"
)
.
type
(
"Object"
)
...
...
@@ -490,7 +492,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
RequestBuilder
request
=
get
(
"/projects/{projectId}/models/{mapId}/bioEntities:search?query=
p
1"
,
TEST_PROJECT
,
"*"
);
"/projects/{projectId}/models/{mapId}/bioEntities:search?query=
s
1"
,
TEST_PROJECT
,
"*"
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"projects/project_maps/search_by_query"
,
...
...
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTestWithoutTransaction.java
View file @
d8bedcd9
...
...
@@ -24,8 +24,6 @@ import lcsb.mapviewer.services.interfaces.IModelService;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
MapControllerIntegrationTestWithoutTransaction
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
private
Project
project
;
...
...
web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -53,7 +53,6 @@ import lcsb.mapviewer.services.utils.data.ColorSchemaColumn;
@Rollback
public
class
OverlayControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
private
static
final
String
TEST_USER_PASSWORD
=
"test_user_pass"
;
private
static
final
String
TEST_USER_LOGIN
=
"test_user"
;
private
static
final
String
TEST_CURATOR_PASSWORD
=
"test_curator_pass"
;
...
...
web/src/test/java/lcsb/mapviewer/web/ParameterControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -31,8 +31,6 @@ import lcsb.mapviewer.services.interfaces.IModelService;
@Rollback
public
class
ParameterControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Project
project
;
ModelData
map
;
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -14,8 +14,7 @@ import org.apache.http.message.BasicNameValuePair;
import
org.apache.http.util.EntityUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
...
...
@@ -33,6 +32,7 @@ import lcsb.mapviewer.model.security.Privilege;
import
lcsb.mapviewer.model.security.PrivilegeType
;
import
lcsb.mapviewer.model.user.User
;
import
lcsb.mapviewer.persist.dao.ProjectDao
;
import
lcsb.mapviewer.services.interfaces.IModelService
;
import
lcsb.mapviewer.services.interfaces.IUserService
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
...
...
@@ -40,7 +40,6 @@ import lcsb.mapviewer.services.interfaces.IUserService;
@Rollback
public
class
ProjectControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
private
static
final
String
CURATOR_PASSWORD
=
"test_pass"
;
private
static
final
String
CURATOR_LOGIN
=
"test_user"
;
Logger
logger
=
LogManager
.
getLogger
();
...
...
@@ -60,11 +59,17 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
curator
=
createCurator
(
CURATOR_LOGIN
,
CURATOR_PASSWORD
);
}
@Autowired
private
IModelService
modelService
;
@After
public
void
tearDown
()
{
modelService
.
removeModelFromCacheByProjectId
(
TEST_PROJECT
);
}
@Test
public
void
testGetAllProjectsAsAdmin
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
RequestBuilder
request
=
get
(
"/projects/"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
String
response
=
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
is2xxSuccessful
())
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTestForAsyncCalls.java
View file @
d8bedcd9
...
...
@@ -37,7 +37,6 @@ import lcsb.mapviewer.services.interfaces.IUserService;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
ProjectControllerIntegrationTestForAsyncCalls
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
private
static
final
String
CURATOR_PASSWORD
=
"curator_pass"
;
private
static
final
String
CURATOR_LOGIN
=
"test_curator"
;
private
static
final
String
ADMIN_PASSWORD
=
"admin_pass"
;
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTestWithoutTransaction.java
View file @
d8bedcd9
...
...
@@ -41,8 +41,6 @@ public class ProjectControllerIntegrationTestWithoutTransaction extends Controll
private
static
final
String
BUILT_IN_ADMIN_PASSWORD
=
"admin"
;
private
static
final
String
BUILT_IN_ADMIN_LOGIN
=
"admin"
;
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
@Autowired
private
IUserService
userService
;
...
...
web/src/test/java/lcsb/mapviewer/web/PublicationsControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -20,14 +20,13 @@ import org.springframework.transaction.annotation.Transactional;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.model.ModelData
;
import
lcsb.mapviewer.persist.dao.ProjectDao
;
import
lcsb.mapviewer.services.interfaces.IModelService
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@Transactional
@Rollback
public
class
PublicationsControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
@Autowired
...
...
@@ -36,6 +35,9 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration
private
Project
project
;
private
ModelData
map
;
@Autowired
private
IModelService
modelService
;
@Before
public
void
setup
()
{
project
=
projectDao
.
getProjectByProjectId
(
BUILT_IN_PROJECT
);
...
...
@@ -44,6 +46,7 @@ public class PublicationsControllerIntegrationTest extends ControllerIntegration
@After
public
void
tearDown
()
{
modelService
.
removeModelFromCacheByProjectId
(
TEST_PROJECT
);
}
@Test
...
...
web/src/test/java/lcsb/mapviewer/web/ReactionControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -31,8 +31,6 @@ import lcsb.mapviewer.services.interfaces.IUserService;
@Rollback
public
class
ReactionControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
@Autowired
...
...
web/src/test/java/lcsb/mapviewer/web/UnitsControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -30,8 +30,6 @@ import lcsb.mapviewer.services.interfaces.IModelService;
@Rollback
public
class
UnitsControllerIntegrationTest
extends
ControllerIntegrationTest
{
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Project
project
;
ModelData
map
;
...
...
web/src/test/java/lcsb/mapviewer/web/UserControllerIntegrationTest.java
View file @
d8bedcd9
...
...
@@ -11,8 +11,7 @@ import org.apache.http.message.BasicNameValuePair;
import
org.apache.http.util.EntityUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.*
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -33,8 +32,7 @@ import lcsb.mapviewer.model.user.*;
import
lcsb.mapviewer.persist.dao.ProjectDao
;
import
lcsb.mapviewer.persist.dao.map.LayoutDao
;
import
lcsb.mapviewer.persist.dao.user.ResetPasswordTokenDao
;
import
lcsb.mapviewer.services.interfaces.IConfigurationService
;
import
lcsb.mapviewer.services.interfaces.IUserService
;
import
lcsb.mapviewer.services.interfaces.*
;
import
lcsb.mapviewer.services.utils.EmailSender
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
...
...
@@ -47,7 +45,6 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
private
static
final
String
TEST_USER_LOGIN
=
"test_user"
;
private
static
final
String
TEST_ADMIN_PASSWORD
=
"test_admin"
;
private
static
final
String
TEST_ADMIN_LOGIN
=
"test_admin"
;
private
static
final
String
TEST_PROJECT
=
"test_project"
;
Logger
logger
=
LogManager
.
getLogger
();
private
User
user
;
private
User
admin
;
...
...
@@ -70,6 +67,9 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Autowired
private
LayoutDao
layoutDao
;
@Autowired
private
IModelService
modelService
;
@Before
public
void
setup
()
{
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
...
...
@@ -77,6 +77,11 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
userService
.
grantUserPrivilege
(
admin
,
PrivilegeType
.
IS_ADMIN
);
}
@After
public
void
tearDown
()
{
modelService
.
removeModelFromCacheByProjectId
(
TEST_PROJECT
);
}
@Test
public
void
grantPrivilege
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
...
...
@@ -130,7 +135,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Test
public
void
grantProjectPrivilege
()
throws
Exception
{
Project
project
=
new
Project
(
"test_project"
);
Project
project
=
new
Project
(
TEST_PROJECT
);
project
.
setOwner
(
userService
.
getUserByLogin
(
BUILT_IN_TEST_ADMIN_LOGIN
));
projectDao
.
add
(
project
);
...
...
@@ -196,7 +201,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Test
public
void
revokeProjectPrivilege
()
throws
Exception
{
Project
project
=
new
Project
(
"test_project"
);
Project
project
=
new
Project
(
TEST_PROJECT
);
project
.
setOwner
(
userService
.
getUserByLogin
(
BUILT_IN_TEST_ADMIN_LOGIN
));
projectDao
.
add
(
project
);
...
...
@@ -456,7 +461,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
public
void
removeUserWithLayouts
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
Project
project
=
new
Project
(
"test_project"
);
Project
project
=
new
Project
(
TEST_PROJECT
);
project
.
setOwner
(
userService
.
getUserByLogin
(
BUILT_IN_TEST_ADMIN_LOGIN
));
projectDao
.
add
(
project
);
...
...
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