Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse openK User Modules
org.eclipse.openk-usermodules.gridFailureInformation.backend
Commits
23764554
Commit
23764554
authored
Feb 28, 2020
by
dietricf
Browse files
SONARWORK
parent
f1d39e81
Changes
1
Hide whitespace changes
Inline
Side-by-side
gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/VersionControllerTest.java
View file @
23764554
...
...
@@ -15,6 +15,8 @@
package
org.eclipse.openk.gridfailureinformation.controller
;
import
org.eclipse.openk.gridfailureinformation.GridFailureInformationApplication
;
import
org.eclipse.openk.gridfailureinformation.enums.OperationType
;
import
org.eclipse.openk.gridfailureinformation.exceptions.*
;
import
org.eclipse.openk.gridfailureinformation.service.VersionService
;
import
org.eclipse.openk.gridfailureinformation.support.MockDataHelper
;
import
org.eclipse.openk.gridfailureinformation.viewmodel.VersionDto
;
...
...
@@ -23,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
...
...
@@ -54,4 +57,45 @@ public class VersionControllerTest {
.
andExpect
(
jsonPath
(
"dbVersion"
,
is
(
"550"
)));
}
@Test
public
void
shouldRaiseBadRequest1
()
throws
Exception
{
checkException
(
new
BadRequestException
(),
HttpStatus
.
BAD_REQUEST
.
value
());
};
@Test
public
void
shouldRaiseBadRequest2
()
throws
Exception
{
checkException
(
new
BadRequestException
(
"test"
),
HttpStatus
.
BAD_REQUEST
.
value
());
};
@Test
public
void
shouldRaiseConflict
()
throws
Exception
{
checkException
(
new
ConflictException
(
"test"
),
HttpStatus
.
CONFLICT
.
value
());
};
@Test
public
void
shouldRaiseInternalServer
()
throws
Exception
{
checkException
(
new
InternalServerErrorException
(
"test"
),
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
};
@Test
public
void
shouldRaiseNotFound
()
throws
Exception
{
checkException
(
new
NotFoundException
(
"test"
),
HttpStatus
.
NOT_FOUND
.
value
());
};
@Test
public
void
shouldRaiseNotAcceptable
()
throws
Exception
{
checkException
(
new
OperationDeniedException
(
OperationType
.
CREATE
,
"test"
),
HttpStatus
.
NOT_ACCEPTABLE
.
value
());
};
@Test
public
void
shouldRaiseUnautorized
()
throws
Exception
{
checkException
(
new
UnauthorizedException
(
"test"
),
HttpStatus
.
UNAUTHORIZED
.
value
());
};
@Test
private
void
checkException
(
Exception
ex
,
int
codeToCheck
)
throws
Exception
{
when
(
versionService
.
getVersion
()).
thenThrow
(
ex
);
mockMvc
.
perform
(
get
(
"/version"
)).
andExpect
(
status
().
is
(
codeToCheck
));
}
}
\ No newline at end of file
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