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
d29bceb6
Commit
d29bceb6
authored
Aug 22, 2019
by
Piotr Gawron
Browse files
tests checking if undefined project is handled properly
parent
921e0fb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java
View file @
d29bceb6
...
...
@@ -95,6 +95,22 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.
getAsJsonArray
().
size
());
}
@Test
public
void
testListOfCommentsWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
createComments
();
RequestBuilder
request
=
get
(
"/projects/*/comments/models/"
+
map
.
getIdModel
()
+
"/"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testCuratorSeesAllComments
()
throws
Exception
{
User
curator
=
createCurator
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -354,6 +370,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.
getAsJsonArray
().
size
());
}
@Test
public
void
testGetReactionCommentsWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Comment
comment
=
createReactionComment
();
commentDao
.
add
(
comment
);
RequestBuilder
request
=
get
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/bioEntities/reactions/"
+
reaction
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testGetReactionCommentsAsCurator
()
throws
Exception
{
User
curator
=
createCurator
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -419,6 +453,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.
getAsJsonArray
().
size
());
}
@Test
public
void
testGetElementCommentsWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Comment
comment
=
createElementComment
();
commentDao
.
add
(
comment
);
RequestBuilder
request
=
get
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/bioEntities/elements/"
+
element
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testGetElementCommentsAsCurator
()
throws
Exception
{
User
curator
=
createCurator
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -484,6 +536,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.
getAsJsonArray
().
size
());
}
@Test
public
void
testGetPointCommentsWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Comment
comment
=
createComment
();
commentDao
.
add
(
comment
);
RequestBuilder
request
=
get
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/points/10.00,20.00"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testGetPointCommentsAsCurator
()
throws
Exception
{
User
curator
=
createCurator
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -552,6 +622,30 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals
(
1
,
commentDao
.
getCommentByModel
(
map
,
null
,
null
).
size
());
}
@Test
public
void
testAddElementCommentWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
String
body
=
EntityUtils
.
toString
(
new
UrlEncodedFormEntity
(
Arrays
.
asList
(
new
BasicNameValuePair
(
"name"
,
"test_user"
),
new
BasicNameValuePair
(
"email"
,
"a@a.lu"
),
new
BasicNameValuePair
(
"content"
,
"tes content"
),
new
BasicNameValuePair
(
"pinned"
,
"true"
),
new
BasicNameValuePair
(
"coordinates"
,
"10,2"
),
new
BasicNameValuePair
(
"modelId"
,
map
.
getId
().
toString
()))));
RequestBuilder
request
=
post
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/bioEntities/elements/"
+
element
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
body
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testAddElementCommentWithoutAllNecessaryData
()
throws
Exception
{
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
map
.
getProject
());
...
...
@@ -650,6 +744,30 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals
(
1
,
commentDao
.
getCommentByModel
(
map
,
null
,
null
).
size
());
}
@Test
public
void
testAddReactionCommentWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
String
body
=
EntityUtils
.
toString
(
new
UrlEncodedFormEntity
(
Arrays
.
asList
(
new
BasicNameValuePair
(
"name"
,
"test_user"
),
new
BasicNameValuePair
(
"email"
,
"a@a.lu"
),
new
BasicNameValuePair
(
"content"
,
"tes content"
),
new
BasicNameValuePair
(
"pinned"
,
"true"
),
new
BasicNameValuePair
(
"coordinates"
,
"10,2"
),
new
BasicNameValuePair
(
"modelId"
,
map
.
getId
().
toString
()))));
RequestBuilder
request
=
post
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/bioEntities/reactions/"
+
reaction
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
body
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testAddPointCommentAsUserWithAccess
()
throws
Exception
{
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
map
.
getProject
());
...
...
@@ -700,6 +818,29 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals
(
1
,
commentDao
.
getCommentByModel
(
map
,
null
,
null
).
size
());
}
@Test
public
void
testAddPointCommentWithUndefinedProject
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
String
body
=
EntityUtils
.
toString
(
new
UrlEncodedFormEntity
(
Arrays
.
asList
(
new
BasicNameValuePair
(
"name"
,
"test_user"
),
new
BasicNameValuePair
(
"email"
,
"a@a.lu"
),
new
BasicNameValuePair
(
"content"
,
"tes content"
),
new
BasicNameValuePair
(
"pinned"
,
"true"
),
new
BasicNameValuePair
(
"modelId"
,
map
.
getId
().
toString
()))));
RequestBuilder
request
=
post
(
"/projects/*/comments/models/"
+
map
.
getId
()
+
"/points/10,2"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
body
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
private
Comment
createComment
()
{
Comment
comment
=
new
Comment
();
comment
.
setModel
(
map
);
...
...
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