Skip to content

Commit 8c47d2e

Browse files
committed
Fixed broken tests
1 parent 9c24d6b commit 8c47d2e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Hello World!Input file: inputMapping schema file: schema
1+
Hello World!

src/test/java/edu/kit/datamanager/mappingservice/rest/impl/MappingAdministrationControllerTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.nio.file.Files;
6060
import java.nio.file.Path;
6161
import java.nio.file.Paths;
62+
import java.util.Arrays;
6263
import java.util.Comparator;
6364
import java.util.HashSet;
6465
import java.util.Set;
@@ -412,7 +413,13 @@ public void testGetMappingDocumentByIdWithInvalidMapping() throws UnsupportedEnc
412413
public void testUpdateMapping() throws JsonProcessingException, Exception {
413414
System.out.println("updateMapping");
414415
testCreateMapping();
415-
File mappingsDir = Paths.get(TEMP_DIR_4_MAPPING).toFile();
416+
417+
System.out.println("mapp");
418+
419+
String schemaDir = TEMP_DIR_4_MAPPING + "mappingSchemas/";
420+
File mappingsDir = Paths.get(schemaDir).toFile();
421+
System.out.println("DIR " + mappingsDir);
422+
System.out.println("LIST " + Arrays.asList(mappingsDir.list()));
416423
String mappingId = MAPPING_ID;
417424
String mappingType = MAPPING_TYPE;
418425
String getMappingIdUrl = "/api/v1/mappingAdministration/" + mappingId;
@@ -434,6 +441,8 @@ public void testUpdateMapping() throws JsonProcessingException, Exception {
434441
result = this.mockMvc.perform(MockMvcRequestBuilders.multipart(putMappingIdUrl).
435442
file(recordFile).
436443
file(mappingFile).header("If-Match", etag).with(putMultipart())).andDo(print()).andExpect(status().isOk()).andReturn();
444+
System.out.println("LIST AF " + Arrays.asList(mappingsDir.list()));
445+
437446
assertEquals(2, mappingsDir.list().length);
438447
ObjectMapper map = new ObjectMapper();
439448
MappingRecord resultRecord = map.readValue(result.getResponse().getContentAsString(), MappingRecord.class);
@@ -774,7 +783,7 @@ public void testDeleteMappingUnknownMappingId() throws JsonProcessingException,
774783
result = this.mockMvc.perform(delete(deleteMappingIdUrl).header("If-Match", etag)).andDo(print()).andExpect(status().isNotFound()).andReturn();
775784
assertEquals(1, mappingsDir.list().length);
776785
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
777-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
786+
assertEquals("my_dc_GEMMA.mapping", expectedFilename);
778787
assertEquals(1, mappingRecordDao.count());
779788
}
780789

@@ -820,7 +829,7 @@ public void testDeleteMappingMissingEtag() throws JsonProcessingException, Excep
820829
result = this.mockMvc.perform(delete(deleteMappingIdUrl)).andDo(print()).andExpect(status().isPreconditionRequired()).andReturn();
821830
assertEquals(1, mappingsDir.list().length);
822831
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
823-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
832+
assertEquals("my_dc_GEMMA.mapping", expectedFilename);
824833
result = this.mockMvc.perform(get(getMappingIdUrl).header("Accept", MappingRecord.MAPPING_RECORD_MEDIA_TYPE)).andDo(print()).andExpect(status().isOk()).andReturn();
825834
assertEquals(1, mappingRecordDao.count());
826835
}
@@ -844,7 +853,7 @@ public void testDeleteMappingWrongEtag() throws JsonProcessingException, Excepti
844853
result = this.mockMvc.perform(delete(deleteMappingIdUrl).header("If-Match", etag)).andDo(print()).andExpect(status().isPreconditionFailed()).andReturn();
845854
assertEquals(1, mappingsDir.list().length);
846855
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
847-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
856+
assertEquals("my_dc_GEMMA.mapping", expectedFilename);
848857
result = this.mockMvc.perform(get(getMappingIdUrl).header("Accept", MappingRecord.MAPPING_RECORD_MEDIA_TYPE)).andDo(print()).andExpect(status().isOk()).andReturn();
849858
assertEquals(1, mappingRecordDao.count());
850859
}

0 commit comments

Comments
 (0)