Skip to content

Commit dbc8bd3

Browse files
authored
Merge pull request #48 from open-simulation-platform/develop
Develop
2 parents f2a70e0 + f5d6491 commit dbc8bd3

26 files changed

Lines changed: 139 additions & 112 deletions

File tree

osp-model-description-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

osp-model-description/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

osp-system-structure-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

osp-system-structure-cli/src/main/java/com/opensimulationplatform/systemstructure/cli/CommandLineInterface.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.slf4j.LoggerFactory;
1111

1212
import java.io.File;
13+
import java.util.List;
1314

1415
import static java.util.Objects.nonNull;
1516

@@ -36,7 +37,10 @@ public static void main(String[] args) {
3637
}
3738

3839
LOG.error("--- Message ---");
39-
String[] lines = result.getDiagnostics().getMessage().split("\n");
40+
StringBuilder messageBuilder = new StringBuilder();
41+
List<SystemStructureValidator.Diagnostic> diagnostics = result.getDiagnostics();
42+
diagnostics.forEach(d -> messageBuilder.append(d.getMessage()).append("\n"));
43+
String[] lines = messageBuilder.toString().split("\n");
4044
for (String line : lines) {
4145
LOG.error(line);
4246
}

osp-system-structure-http/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

osp-system-structure-http/src/main/java/com/opensimulationplatform/systemstructure/http/ValidationServlet.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.PrintWriter;
1616
import java.net.URI;
1717
import java.net.URL;
18+
import java.util.List;
1819

1920
import static java.util.Objects.nonNull;
2021

@@ -96,13 +97,21 @@ private ValidationServletResponse getServletResponse(SystemStructureValidator.Re
9697
response.setValid("true");
9798
} else {
9899
response.setValid("false");
99-
100-
response.setMessage(result.getDiagnostics().getMessage());
100+
response.setMessage(getResponseMessage(result));
101101
}
102102

103103
return response;
104104
}
105105

106+
private String getResponseMessage(SystemStructureValidator.Result result) {
107+
StringBuilder messageBuilder = new StringBuilder();
108+
List<SystemStructureValidator.Diagnostic> diagnostics = result.getDiagnostics();
109+
diagnostics.forEach(d -> {
110+
messageBuilder.append(d.getMessage()).append("\n");
111+
});
112+
return messageBuilder.toString().trim();
113+
}
114+
106115
private URI getURI(String value) {
107116
try {
108117
LOG.debug("Attempting to parse: '" + value + "' as a URI...");

osp-system-structure-http/src/test/java/com/opensimulationplatform/systemstructure/http/ValidationServerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void canHandleGetRequestWithInvalidConfiguration() throws Exception {
7373
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_velocity_plug_velocity\n" +
7474
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_generic_plug_actuatorLimits\n" +
7575
"simulator_CraneController_velocity_socket_velocity Type socket\n" +
76-
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity\n", response.getMessage());
76+
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity", response.getMessage());
7777
}
7878

7979
@Test
@@ -123,7 +123,7 @@ public void canHandleMultiPartPostRequestWithInvalidConfiguration() throws Excep
123123
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_velocity_plug_velocity\n" +
124124
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_generic_plug_actuatorLimits\n" +
125125
"simulator_CraneController_velocity_socket_velocity Type socket\n" +
126-
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity\n", response.getMessage());
126+
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity", response.getMessage());
127127
}
128128

129129
@Test

osp-system-structure-http/src/test/java/com/opensimulationplatform/systemstructure/http/ValidationServletTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void canCallDoGetOnInvalidConfiguration() {
7878
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_velocity_plug_velocity\n" +
7979
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_generic_plug_actuatorLimits\n" +
8080
"simulator_CraneController_velocity_socket_velocity Type socket\n" +
81-
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity\n", response.getMessage());
81+
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity", response.getMessage());
8282
}
8383

8484
@Test
@@ -117,6 +117,6 @@ public void canCallDoPostOnInvalidConfiguration() {
117117
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_velocity_plug_velocity\n" +
118118
"simulator_CraneController_velocity_socket_velocity has_plug_mate simulator_KnuckleBoomCrane_generic_plug_actuatorLimits\n" +
119119
"simulator_CraneController_velocity_socket_velocity Type socket\n" +
120-
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity\n", response.getMessage());
120+
"simulator_KnuckleBoomCrane_velocity_plug_velocity Type velocity", response.getMessage());
121121
}
122122
}

osp-system-structure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

osp-validator-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>msmi-validator</artifactId>
77
<groupId>com.opensimulationplatform</groupId>
8-
<version>0.6.0-SNAPSHOT</version>
8+
<version>0.7.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)