From 66cc0201ddcb8a3dc05585b39d76a76add03adf5 Mon Sep 17 00:00:00 2001
From: Christoph Thelen <christoph.thelen@mni.thm.de>
Date: Mon, 3 Jun 2019 17:21:59 +0200
Subject: [PATCH] Add additional profile to exclude Controller from other tests

This solves the IllegalStateExceptions occurring for most of the other
test cases.

However, we now have the old problem that different Repositories are
injected into objects. In my case, the testCaching case of the
DefaultEntityServiceImplTest stops working, because it gets a different
RoomRepository than the ApplicationPermissionEvaluator.

This behavior is caused by the introduction of the additional profile.
---
 .../thm/arsnova/controller/JsonViewControllerAdviceTest.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/test/java/de/thm/arsnova/controller/JsonViewControllerAdviceTest.java b/src/test/java/de/thm/arsnova/controller/JsonViewControllerAdviceTest.java
index d96815447..7844b1c0a 100644
--- a/src/test/java/de/thm/arsnova/controller/JsonViewControllerAdviceTest.java
+++ b/src/test/java/de/thm/arsnova/controller/JsonViewControllerAdviceTest.java
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Profile;
 import org.springframework.http.MediaType;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.test.context.ActiveProfiles;
@@ -68,7 +69,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 		TestPersistanceConfig.class,
 		TestSecurityConfig.class,
 		WebSocketConfig.class})
-@ActiveProfiles("test")
+@ActiveProfiles({"test", "w/DummyEntityController"})
 public class JsonViewControllerAdviceTest {
 	private static final Logger logger = LoggerFactory.getLogger(JsonViewControllerAdviceTest.class);
 
@@ -149,6 +150,7 @@ public class JsonViewControllerAdviceTest {
 				.andExpect(jsonPath("$.publicReadableString").exists());
 	}
 
+	@Profile("w/DummyEntityController")
 	@RestController
 	@RequestMapping(DummyEntityController.REQUEST_MAPPING)
 	static class DummyEntityController extends AbstractEntityController<DummyEntity> {
-- 
GitLab