yesamer commented on code in PR #6254:
URL:
https://github.com/apache/incubator-kie-drools/pull/6254#discussion_r1957774996
##########
drools-scenario-simulation/drools-scenario-simulation-backend/src/test/java/org/drools/scenariosimulation/backend/util/ScenarioSimulationXMLPersistenceTest.java:
##########
@@ -349,24 +353,58 @@ public void migrateIfNecessary() throws Exception {
}
@Test
- public void extractVersion() {
- String version = instance.extractVersion("<ScenarioSimulationModel
version=\"1.0\" version=\"1.1\">");
- assertThat(version).isEqualTo("1.0");
+ public void extractVersionNullDocument() {
+ assertThatThrownBy(() -> instance.extractVersion(null))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void extractVersionWhenXmlPrologIsPresent() {
- String version = instance.extractVersion("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
-
"<ScenarioSimulationModel version=\"1.1\">");
+ public void extractVersionMissingAttribute() {
+ assertThatThrownBy(() ->
instance.extractVersion(DOMParserUtil.getDocument("<ScenarioSimulationModel
/>")))
+ .isInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ public void extractVersionWhenXmlPrologIsPresent() throws
ParserConfigurationException, IOException, SAXException {
+ String version =
instance.extractVersion(DOMParserUtil.getDocument("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<ScenarioSimulationModel version=\"1.1\" />"));
assertThat(version).isEqualTo("1.1");
}
@Test
- public void extractVersionWhenMoreVersionAttributesArePresent() {
- String version = instance.extractVersion("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
-
"<ScenarioSimulationModel version=\"1.2\">\n" +
- "<someUnknownTag
version=\"1.1\"/>\n" +
-
"</ScenarioSimulationModel>");
+ public void
extractVersionWhenXmlPrologIsPresentAndWithMultipleAttributes1() throws
ParserConfigurationException, IOException, SAXException {
+ String version =
instance.extractVersion(DOMParserUtil.getDocument("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<ScenarioSimulationModel version=\"1.1\"
attribute1=\"whatever\" />"));
+ assertThat(version).isEqualTo("1.1");
+ }
+
+ @Test
+ public void
extractVersionWhenXmlPrologIsPresentAndWithMultipleAttributes2() throws
ParserConfigurationException, IOException, SAXException {
+ String version =
instance.extractVersion(DOMParserUtil.getDocument("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<ScenarioSimulationModel attribute1=\"whatever\"
version=\"1.2\" />"));
+ assertThat(version).isEqualTo("1.2");
+ }
+
+ @Test
+ public void
extractVersionWhenXmlPrologIsPresentAndWithMultipleAttributes3() throws
ParserConfigurationException, IOException, SAXException {
+ String version =
instance.extractVersion(DOMParserUtil.getDocument("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<ScenarioSimulationModel attribute2=\"whatever\"
version=\"1.3\" attribute1=\"whatever\" />"));
+ assertThat(version).isEqualTo("1.3");
+ }
+
+ @Test
+ public void
extractVersionWhenXmlPrologIsPresentAndWithMultipleAttributes4() throws
ParserConfigurationException, IOException, SAXException {
+ String version =
instance.extractVersion(DOMParserUtil.getDocument("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<ScenarioSimulationModel attribute2=\"whatever\"
attribute1=\"whatever\" version=\"1.4\" />"));
+ assertThat(version).isEqualTo("1.4");
+ }
+
Review Comment:
Thank you @pibizza, that was my first intent, but scesim module is still
based on JUnit 4, so I preferred to don't introduce Junit4 Parametrized tests
in this class. About the explanation string, which approach do you suggest,
please?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]