TSK-939: Fix race conditions in tests
This commit is contained in:
parent
d42e6e1d29
commit
53e897a020
|
|
@ -12,9 +12,11 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
|
@ -35,6 +37,7 @@ import pro.taskana.rest.RestConfiguration;
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class WorkbasketAccessItemControllerRestDocumentation {
|
public class WorkbasketAccessItemControllerRestDocumentation {
|
||||||
|
|
||||||
@LocalServerPort
|
@LocalServerPort
|
||||||
|
|
@ -147,11 +150,11 @@ public class WorkbasketAccessItemControllerRestDocumentation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWorkbasketAccessItemsDocTest() throws Exception {
|
public void test01_getWorkbasketAccessItemsDocTest() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(RestDocumentationRequestBuilders
|
.perform(RestDocumentationRequestBuilders
|
||||||
.get("http://127.0.0.1:" + port
|
.get("http://127.0.0.1:" + port
|
||||||
+ "/api/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1")
|
+ "/api/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_2_2")
|
||||||
.accept("application/hal+json")
|
.accept("application/hal+json")
|
||||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
|
@ -160,10 +163,10 @@ public class WorkbasketAccessItemControllerRestDocumentation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeWorkbasketAccessItemsDocTest() throws Exception {
|
public void test02_removeWorkbasketAccessItemsDocTest() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(RestDocumentationRequestBuilders
|
.perform(RestDocumentationRequestBuilders
|
||||||
.delete("http://127.0.0.1:" + port + "/api/v1/workbasket-access-items/?access-id=user_1_1")
|
.delete("http://127.0.0.1:" + port + "/api/v1/workbasket-access-items/?access-id=user_2_2")
|
||||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||||
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||||
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));
|
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
@ -129,6 +130,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testCreateClassification() throws IOException {
|
public void testCreateClassification() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||||
URL url = new URL(server + port + "/api/v1/classifications");
|
URL url = new URL(server + port + "/api/v1/classifications");
|
||||||
|
|
@ -160,6 +162,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testCreateClassificationWithParentId() throws IOException {
|
public void testCreateClassificationWithParentId() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P1\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P1\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
||||||
URL url = new URL(server + port + "/api/v1/classifications");
|
URL url = new URL(server + port + "/api/v1/classifications");
|
||||||
|
|
@ -177,6 +180,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testCreateClassificationWithParentKey() throws IOException {
|
public void testCreateClassificationWithParentKey() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||||
URL url = new URL(server + port + "/api/v1/classifications");
|
URL url = new URL(server + port + "/api/v1/classifications");
|
||||||
|
|
@ -194,6 +198,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testCreateClassificationWithParentKeyInDOMAIN_AShouldCreateAClassificationInRootDomain()
|
public void testCreateClassificationWithParentKeyInDOMAIN_AShouldCreateAClassificationInRootDomain()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||||
|
|
@ -228,6 +233,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testReturn400IfCreateClassificationWithIncompatibleParentIdAndKey() throws IOException {
|
public void testReturn400IfCreateClassificationWithIncompatibleParentIdAndKey() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\",\"parentKey\":\"T2000\"}";
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\",\"parentKey\":\"T2000\"}";
|
||||||
URL url = new URL(server + port + "/api/v1/classifications");
|
URL url = new URL(server + port + "/api/v1/classifications");
|
||||||
|
|
@ -245,6 +251,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DirtiesContext
|
||||||
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
|
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||||
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/classifications");
|
URL url = new URL("http://127.0.0.1:" + port + "/api/v1/classifications");
|
||||||
|
|
@ -276,6 +283,7 @@ public class ClassificationControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = HttpClientErrorException.class)
|
@Test(expected = HttpClientErrorException.class)
|
||||||
|
@DirtiesContext
|
||||||
public void testDeleteClassification() {
|
public void testDeleteClassification() {
|
||||||
RestTemplate template = getRestTemplate();
|
RestTemplate template = getRestTemplate();
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue