Commit a021992e authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Send ServiceUnavailable response if no UniRepService is configured

parent e2622393
......@@ -2,11 +2,12 @@ package de.thm.arsnova.connector.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.Sha512DigestUtils;
import org.springframework.stereotype.Service;
import de.thm.arsnova.connector.persistence.domain.User;
import de.thm.arsnova.connector.persistence.repository.UserRepository;
@Service
public class InternalUserServiceImpl implements InternalUserService {
@Autowired
......
......@@ -33,6 +33,10 @@ public class UniRepController {
@RequestMapping("/{refId}")
public HttpEntity<IliasCategoryNode> getIliasTreeObjects(@PathVariable int refId) {
if (service == null) {
return new ResponseEntity<IliasCategoryNode>(new IliasCategoryNode(), HttpStatus.SERVICE_UNAVAILABLE);
}
try {
IliasCategoryNode node = service.getTreeObjects(refId);
return new ResponseEntity<IliasCategoryNode>(node, HttpStatus.OK);
......@@ -46,6 +50,10 @@ public class UniRepController {
@PathVariable int refId,
@RequestParam(value = "source", defaultValue = "RANDOM_TEST") QuestionSource source
) {
if (service == null) {
return new ResponseEntity<List<IliasQuestion>>(new ArrayList<IliasQuestion>(), HttpStatus.SERVICE_UNAVAILABLE);
}
try {
switch (source) {
case QUESTION_POOL:
......
......@@ -102,4 +102,11 @@ public class WebDomainIntegrationTest {
fail("AccessDeniedException expected");
}
@Test
public void testShouldGetServiceUnavailableResponse() throws Exception {
mockMvc.perform(get("/ilias/question/123").param("source", "QUESTION_POOL").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isServiceUnavailable())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
}
Supports Markdown
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