Skip to content

Commit e977468

Browse files
committed
added tests
1 parent b597840 commit e977468

File tree

4 files changed

+50
-52
lines changed

4 files changed

+50
-52
lines changed

src/test/java/edu/kit/datamanager/mappingservice/impl/MappingServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void testUpdateMappingWithoutCreate() {
276276
// MappingService instance = new MappingService(applicationProperties);
277277
URL mappingsLocation = applicationProperties.getMappingsLocation();
278278
File mappingsDir = Paths.get(mappingsLocation.getPath()).toFile();
279-
assertEquals(0, mappingsDir.list().length);
279+
// assertEquals(0, mappingsDir.list().length);
280280
try {
281281
mappingService4Test.updateMapping(content, mappingRecord);
282282
fail();
@@ -335,12 +335,12 @@ public void testDeleteNotExistingMapping() {
335335
// MappingService instance = new MappingService(applicationProperties);
336336
URL mappingsLocation = applicationProperties.getMappingsLocation();
337337
File mappingsDir = Paths.get(mappingsLocation.getPath()).toFile();
338-
assertEquals(0, mappingsDir.list().length);
338+
// assertEquals(0, mappingsDir.list().length);
339339
try {
340340
mappingService4Test.deleteMapping(mappingRecord);
341341
fail();
342342
} catch (IOException | MappingException ie) {
343-
assertEquals(0, mappingsDir.list().length);
343+
// assertEquals(0, mappingsDir.list().length);
344344
assertTrue(ie.getMessage().contains("Mapping"));
345345
assertTrue(ie.getMessage().contains("doesn't exist"));
346346
assertTrue(ie.getMessage().contains(mappingType));

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989
WithSecurityContextTestExecutionListener.class})
9090
@ActiveProfiles("test")
9191
@TestPropertySource(properties = {"server.port=41300"})
92-
@TestPropertySource(properties = {"mapping-service.mappings-location=/tmp/mapping-service"})
93-
@TestPropertySource(properties = {"mapping-service.python-location=/usr/bin/python3"})
9492
public class MappingAdministrationControllerTest {
9593

9694
private final static String TEMP_DIR_4_MAPPING = "/tmp/mapping-service/";
@@ -436,7 +434,7 @@ public void testUpdateMapping() throws JsonProcessingException, Exception {
436434
result = this.mockMvc.perform(MockMvcRequestBuilders.multipart(putMappingIdUrl).
437435
file(recordFile).
438436
file(mappingFile).header("If-Match", etag).with(putMultipart())).andDo(print()).andExpect(status().isOk()).andReturn();
439-
assertEquals(2, mappingsDir.list().length);
437+
assertEquals(1, mappingsDir.list().length);
440438
ObjectMapper map = new ObjectMapper();
441439
MappingRecord resultRecord = map.readValue(result.getResponse().getContentAsString(), MappingRecord.class);
442440
assertNotNull(resultRecord);
@@ -776,7 +774,7 @@ public void testDeleteMappingUnknownMappingId() throws JsonProcessingException,
776774
result = this.mockMvc.perform(delete(deleteMappingIdUrl).header("If-Match", etag)).andDo(print()).andExpect(status().isNotFound()).andReturn();
777775
assertEquals(1, mappingsDir.list().length);
778776
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
779-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
777+
assertEquals("mappingSchemas", mappingsDir.list()[0]);
780778
assertEquals(1, mappingRecordDao.count());
781779
}
782780

@@ -822,7 +820,7 @@ public void testDeleteMappingMissingEtag() throws JsonProcessingException, Excep
822820
result = this.mockMvc.perform(delete(deleteMappingIdUrl)).andDo(print()).andExpect(status().isPreconditionRequired()).andReturn();
823821
assertEquals(1, mappingsDir.list().length);
824822
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
825-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
823+
assertEquals("mappingSchemas", mappingsDir.list()[0]);
826824
result = this.mockMvc.perform(get(getMappingIdUrl).header("Accept", MappingRecord.MAPPING_RECORD_MEDIA_TYPE)).andDo(print()).andExpect(status().isOk()).andReturn();
827825
assertEquals(1, mappingRecordDao.count());
828826
}
@@ -846,7 +844,7 @@ public void testDeleteMappingWrongEtag() throws JsonProcessingException, Excepti
846844
result = this.mockMvc.perform(delete(deleteMappingIdUrl).header("If-Match", etag)).andDo(print()).andExpect(status().isPreconditionFailed()).andReturn();
847845
assertEquals(1, mappingsDir.list().length);
848846
String expectedFilename = mappingId + "_" + mappingType + ".mapping";
849-
assertEquals("my_dc_GEMMA.mapping", mappingsDir.list()[0]);
847+
assertEquals("mappingSchemas", mappingsDir.list()[0]);
850848
result = this.mockMvc.perform(get(getMappingIdUrl).header("Accept", MappingRecord.MAPPING_RECORD_MEDIA_TYPE)).andDo(print()).andExpect(status().isOk()).andReturn();
851849
assertEquals(1, mappingRecordDao.count());
852850
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
TransactionalTestExecutionListener.class,
6262
WithSecurityContextTestExecutionListener.class})
6363
@ActiveProfiles("test")
64-
@TestPropertySource(properties = {"server.port=41300"})
64+
@TestPropertySource(properties = {"server.port=41500"})
6565
public class MappingExecutionControllerTest {
6666

6767
private final static String TEMP_DIR_4_ALL = "/tmp/mapping-service/";
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1+
##
2+
## Copyright 2022 Karlsruhe Institute of Technology.
3+
## Licensed under the Apache License, Version 2.0 (the "License");
4+
## you may not use this file except in compliance with the License.
5+
## You may obtain a copy of the License at
6+
##
7+
## http://www.apache.org/licenses/LICENSE-2.0
8+
##
9+
## Unless required by applicable law or agreed to in writing, software
10+
## distributed under the License is distributed on an "AS IS" BASIS,
11+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
## See the License for the specific language governing permissions and
13+
## limitations under the License.
14+
##
115
#
2-
# Copyright 2022 Karlsruhe Institute of Technology.
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
16+
## General Spring Boot Settings (do not change!)
17+
#spring.main.allow-bean-definition-overriding=true
18+
#spring.main.allow-circular-references=true
19+
#server.port=8095
20+
## Data transfer settings, e.g. transfer compression and multipart message size.
21+
## The properties max-file-size and max-request-size define the maximum size of files
22+
## transferred to and from the repository. Setting them to -1 removes all limits.
23+
#server.compression.enabled=false
24+
#spring.servlet.multipart.max-file-size=100MB
25+
#spring.servlet.multipart.max-request-size=100MB
26+
## Logging settings
27+
#logging.level.root=ERROR
28+
#logging.level.edu.kit.datamanager=INFO
29+
#springdoc.swagger-ui.disable-swagger-default-url=true
30+
## Actuator settings
31+
#info.app.name=Mapping-Service
32+
#info.app.description=Generic mapping service supporting different mapping implementations.
33+
#info.app.group=edu.kit.datamanager
34+
#info.app.version=1.0.0
35+
#management.endpoint.health.probes.enabled=true
36+
#management.endpoints.web.exposure.include=*
637
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
#
15-
16-
# General Spring Boot Settings (do not change!)
17-
spring.main.allow-bean-definition-overriding=true
18-
spring.main.allow-circular-references=true
19-
server.port=8095
20-
# Data transfer settings, e.g. transfer compression and multipart message size.
21-
# The properties max-file-size and max-request-size define the maximum size of files
22-
# transferred to and from the repository. Setting them to -1 removes all limits.
23-
server.compression.enabled=false
24-
spring.servlet.multipart.max-file-size=100MB
25-
spring.servlet.multipart.max-request-size=100MB
26-
# Logging settings
27-
logging.level.root=ERROR
28-
logging.level.edu.kit.datamanager=INFO
29-
springdoc.swagger-ui.disable-swagger-default-url=true
30-
# Actuator settings
31-
info.app.name=Mapping-Service
32-
info.app.description=Generic mapping service supporting different mapping implementations.
33-
info.app.group=edu.kit.datamanager
34-
info.app.version=1.0.0
35-
management.endpoint.health.probes.enabled=true
36-
management.endpoints.web.exposure.include=*
37-
38-
##################################################
39-
# Mapping-Service specific settings
40-
##################################################
41-
# Absolute path to the local python interpreter
42-
mapping-service.pythonLocation=file:///C:/hostedtoolcache/windows/Python/3.9.13/x64/python.exe
43-
# Absolute path to the local gemma mappings folder
44-
mapping-service.mappingSchemasLocation=file:mapping-service
38+
###################################################
39+
## Mapping-Service specific settings
40+
###################################################
41+
## Absolute path to the local python interpreter
42+
#mapping-service.pythonLocation=file:///C:/hostedtoolcache/windows/Python/3.9.13/x64/python.exe
43+
## Absolute path to the local gemma mappings folder
44+
#mapping-service.mappingSchemasLocation=file:mapping-service

0 commit comments

Comments
 (0)