diff --git a/de.dlr.sc.virsat.model.concept.test/META-INF/MANIFEST.MF b/de.dlr.sc.virsat.model.concept.test/META-INF/MANIFEST.MF index 013b4d68a5..6837d37aca 100644 --- a/de.dlr.sc.virsat.model.concept.test/META-INF/MANIFEST.MF +++ b/de.dlr.sc.virsat.model.concept.test/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: de.dlr.sc.virsat.external.lib.apache.poi, org.eclipse.xtext.testing, org.eclipse.xtext.xbase.lib, org.eclipse.xtext.xbase.testing, - org.eclipse.xtext.ecore + org.eclipse.xtext.ecore, + de.dlr.sc.virsat.test.utils Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: de.dlr.sc.virsat.model.concept, de.dlr.sc.virsat.model.concept.test diff --git a/de.dlr.sc.virsat.model.concept.test/src/de/dlr/sc/virsat/model/concept/test/util/GeneratorJunitAssert.java b/de.dlr.sc.virsat.model.concept.test/src/de/dlr/sc/virsat/model/concept/test/util/GeneratorJunitAssert.java index fc002658b4..471c1cf146 100644 --- a/de.dlr.sc.virsat.model.concept.test/src/de/dlr/sc/virsat/model/concept/test/util/GeneratorJunitAssert.java +++ b/de.dlr.sc.virsat.model.concept.test/src/de/dlr/sc/virsat/model/concept/test/util/GeneratorJunitAssert.java @@ -10,15 +10,12 @@ package de.dlr.sc.virsat.model.concept.test.util; import java.io.IOException; -import java.io.PrintWriter; -import org.junit.Assert; import de.dlr.sc.virsat.model.concept.test.TestActivator; +import de.dlr.sc.virsat.test.utils.TestUtil; /** * Some special Assert Statements to check the code generators with * reference content stored in the plugin/ test fragment resources - * @author fisc_ph - * */ public class GeneratorJunitAssert { @@ -28,15 +25,6 @@ public class GeneratorJunitAssert { private GeneratorJunitAssert() { } - /** - * Set this flag to output the actual content to the console - */ - - private static final String ENV_VARIABLE_FLUSH_ACTUAL = "flushActualGeneratorFiles"; - private static final String ENV_VARIABLE_FLUSH_ACTUAL_TRUE = "true"; - private static final String ENV_VARIABLE_FLUSH_PATH = "flushActualPath"; - - /** * Method to check content against a reference from the resources folder * @param actual the current content as string @@ -44,26 +32,9 @@ private GeneratorJunitAssert() { * @throws IOException in case the expected content file could not be read */ public static void assertEqualContent(String actual, String expectedFilePath) throws IOException { - - if (ENV_VARIABLE_FLUSH_ACTUAL_TRUE.equalsIgnoreCase(System.getenv(ENV_VARIABLE_FLUSH_ACTUAL))) { - String fileName = System.getenv(ENV_VARIABLE_FLUSH_PATH) + expectedFilePath.substring(expectedFilePath.lastIndexOf('/'), expectedFilePath.length()); - - PrintWriter writer = new PrintWriter(fileName, "UTF-8"); - writer.println(actual); - writer.close(); - return; - } - - String expectedString = TestActivator.getResourceContentAsString(expectedFilePath); - String expectedNoWs = expectedString.replaceAll("\\s+", ""); - String actualNoWs = actual.replaceAll("\\s+", ""); - - if (!expectedNoWs.equals(actualNoWs)) { - Assert.assertEquals("File content for " + expectedFilePath + " is correct", expectedString, actual); - } + TestUtil.assertEqualContent(actual, TestActivator.FRAGMENT_ID, expectedFilePath); } - /** * Method to check content against a reference from the resources folder * @param actual the current content as CharSequence diff --git a/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyFloat.java b/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyFloat.java index 5fc1b3a726..f378bacfa5 100644 --- a/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyFloat.java +++ b/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyFloat.java @@ -75,6 +75,32 @@ public Double getValue() { } } + @XmlJavaTypeAdapter(DoubleAdapter.class) + @XmlElement(nillable = true) + @Schema(description = "Double") + /** + * Convenience Method to directly convert the value to its base unit + * @return the value in its base unit + */ + public Double getValueInBaseUnit() { + if (ti.getValue() == null) { + return Double.NaN; + } else { + return getValueToBaseUnit(); + } + } + + /** + * Convenience method to easily set a value in the frame of base unit and have it + * converted to the currently set unit. + * @param inputValue the value to be set in base unit frame + */ + public void setValueInBaseUnit(Double inputValue) { + if (inputValue != null) { + setValueAsBaseUnit(inputValue); + } + } + /** * Convenience Method to directly convert the value to its base unit * @return the value in its base unit diff --git a/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyInt.java b/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyInt.java index c99c06d3f0..ac5ecc3ad1 100644 --- a/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyInt.java +++ b/de.dlr.sc.virsat.model.edit/src/de/dlr/sc/virsat/model/concept/types/property/BeanPropertyInt.java @@ -10,7 +10,6 @@ package de.dlr.sc.virsat.model.concept.types.property; import jakarta.xml.bind.annotation.XmlElement; - import org.eclipse.emf.common.command.Command; import org.eclipse.emf.edit.command.SetCommand; import org.eclipse.emf.edit.domain.EditingDomain; @@ -65,6 +64,49 @@ public Long getValue() throws NumberFormatException { return null; } + + @XmlElement(nillable = true) + @Schema(description = "Long") + /** + * Convenience Method to directly convert the value to its base unit + * @return the value in its base unit + */ + public Long getValueInBaseUnit() { + if (ti.getValue() == null) { + return null; + } else { + return getValueToBaseUnit(); + } + } + + /** + * Convenience method to easily set a value in the frame of base unit and have it + * converted to the currently set unit. + * @param inputValue the value to be set in base unit frame + */ + public void setValueInBaseUnit(Long inputValue) { + if (inputValue != null) { + setValueAsBaseUnit(inputValue); + } + } + + /** + * Convenience Method to directly convert the value to its base unit + * @return the value in its base unit + */ + public Long getValueToBaseUnit() { + return Double.valueOf(ti.getValueToBaseUnit()).longValue(); + } + + /** + * Convenience method to easily set a value in the frame of base unit and have it + * converted to the currently set unit. + * @param inputValue the value to be set in base unit frame + */ + public void setValueAsBaseUnit(Long inputValue) { + ti.setValueAsBaseUnit(inputValue); + } + @Schema( description = "Always returns constant: \"int\"", example = "int", diff --git a/de.dlr.sc.virsat.model.extension.tests.test/META-INF/MANIFEST.MF b/de.dlr.sc.virsat.model.extension.tests.test/META-INF/MANIFEST.MF index fc200b9602..173897f1be 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/META-INF/MANIFEST.MF +++ b/de.dlr.sc.virsat.model.extension.tests.test/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Require-Bundle: org.junit, de.dlr.sc.virsat.model.ext.core, de.dlr.sc.virsat.external.lib.matlabfile, de.dlr.sc.virsat.build, - org.hamcrest.library + org.hamcrest.library, + de.dlr.sc.virsat.test.utils Export-Package: de.dlr.sc.virsat.model.extension.tests.test Automatic-Module-Name: de.dlr.sc.virsat.model.extension.tests.test diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling.json index ab5c82e7c6..0eb29971e7 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling.json @@ -23,7 +23,8 @@ "propertyType" : "float", "override" : false, "unitBean" : "e2203b42-e703-4429-9bf9-dbd4882c341c", - "value" : 0.0 + "value" : 0.0, + "valueInBaseUnit" : 0.0 }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd80", @@ -31,7 +32,8 @@ "propertyType" : "int", "override" : false, "unitBean" : "e2203b42-e703-4429-9bf9-dbd4882c341c", - "value" : 1 + "value" : 1, + "valueInBaseUnit" : 1000 }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb0", @@ -47,4 +49,4 @@ "override" : false, "value" : "this is a test" } -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling_Defaults.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling_Defaults.json index 1f03d84c66..3cf683789e 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling_Defaults.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryAllProperty_Marshaling_Defaults.json @@ -23,7 +23,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd80", @@ -31,7 +32,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb0", @@ -47,4 +49,4 @@ "override" : false, "value" : null } -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryBeanA_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryBeanA_Marshaling.json index 57b74cba05..e98fe73b11 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryBeanA_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryBeanA_Marshaling.json @@ -2,4 +2,4 @@ "type" : "de.dlr.sc.virsat.model.extension.tests.TestCategoryBeanA", "uuid" : "f34d30b0-80f5-4c96-864f-29ab4d3ae9f2", "name" : "TestCategoryBeanA" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling.json index 9ae81cb188..25da6c258a 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling.json @@ -31,7 +31,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd84", @@ -39,7 +40,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb4", @@ -86,7 +88,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd80", @@ -94,7 +97,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb0", @@ -140,7 +144,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd81", @@ -148,7 +153,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb1", @@ -194,7 +200,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd82", @@ -202,7 +209,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb2", @@ -248,7 +256,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd83", @@ -256,7 +265,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb3", @@ -274,4 +284,4 @@ } } } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling_NullComposition.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling_NullComposition.json index e63383767f..fb168eb78a 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling_NullComposition.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryCompositionArray_Marshaling_NullComposition.json @@ -37,7 +37,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd81", @@ -45,7 +46,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb1", @@ -91,7 +93,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd82", @@ -99,7 +102,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb2", @@ -145,7 +149,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd83", @@ -153,7 +158,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb3", @@ -171,4 +177,4 @@ } } } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling.json index 76a6bd0eac..2e978c4e6d 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling.json @@ -26,7 +26,8 @@ "propertyType" : "float", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testIntBean" : { "uuid" : "0f37aff6-ccc0-436f-a592-bd466f74bd80", @@ -34,7 +35,8 @@ "propertyType" : "int", "override" : false, "unitBean" : null, - "value" : null + "value" : null, + "valueInBaseUnit" : null }, "testResourceBean" : { "uuid" : "fa822159-51a5-4bf2-99cf-e565b67e0eb0", @@ -51,4 +53,4 @@ "value" : "testString" } } -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling_NullComposition.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling_NullComposition.json index ed6a5f3038..c62936ffa7 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling_NullComposition.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryComposition_Marshaling_NullComposition.json @@ -3,4 +3,4 @@ "uuid" : "028a6e1b-e7c4-4937-886b-d65452426bfd", "name" : "TestCategoryComposition", "testSubCategory" : null -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryIntrinsicArray_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryIntrinsicArray_Marshaling.json index ba3694a6f6..1eb3103756 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryIntrinsicArray_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryIntrinsicArray_Marshaling.json @@ -34,4 +34,4 @@ "override" : false, "value" : null } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling.json index 16110bbe77..4fa804e972 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling.json @@ -66,4 +66,4 @@ "override" : false, "value" : "7256e7a2-9a1f-443c-85f8-7b766eac3f50" } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling_NullReference.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling_NullReference.json index 3fec58e55d..604cc8f591 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling_NullReference.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReferenceArray_Marshaling_NullReference.json @@ -54,4 +54,4 @@ "override" : false, "value" : "7256e7a2-9a1f-443c-85f8-7b766eac3f50" } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling.json index e01186efdf..ab5e7abd01 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling.json @@ -4,4 +4,4 @@ "name" : "TestCategoryReference", "testRefCategory" : "f34d30b0-80f5-4c96-864f-29ab4d3ae9f0", "testRefProperty" : "7256e7a2-9a1f-443c-85f8-7b766eac3f50" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling_NullReference.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling_NullReference.json index bd4aec3922..d6a82ba067 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling_NullReference.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestCategoryReference_Marshaling_NullReference.json @@ -4,4 +4,4 @@ "name" : "TestCategoryReference", "testRefCategory" : null, "testRefProperty" : null -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling.json index 70a19dcf15..7a99c08e68 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling.json @@ -25,4 +25,4 @@ "name" : null } ], "assignedDiscipline" : "e4e175f5-88c8-474f-bb25-2cdf1d3061cb" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling_Defaults.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling_Defaults.json index 3738cb44c4..965e23b4fc 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling_Defaults.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/TestStructuralElementInstance_Marshaling_Defaults.json @@ -7,4 +7,4 @@ "children" : [ ], "superSeis" : [ ], "assignedDiscipline" : null -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanPrefix.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanPrefix.json index aea4b962af..403132e457 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanPrefix.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanPrefix.json @@ -3,4 +3,4 @@ "factor" : 1000.0, "name" : "kilo", "symbol" : "k" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindDerived.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindDerived.json index b2b1dcf6b7..6c3877861f 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindDerived.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindDerived.json @@ -12,4 +12,4 @@ "exponent" : 1.0, "quantityKindBean" : "882b2e01-712d-4557-bc25-3158cd4ff316" } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindSimple.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindSimple.json index ea1182c498..8bed88b7fb 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindSimple.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanQuantityKindSimple.json @@ -3,4 +3,4 @@ "uuid" : "882b2e01-712d-4557-bc25-3158cd4ff316", "name" : "Length", "symbol" : "L" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitAffineConversion.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitAffineConversion.json index d53aded6fe..f68b81a8ef 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitAffineConversion.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitAffineConversion.json @@ -6,4 +6,4 @@ "symbol" : "min", "factor" : 60.0, "offset" : 0.0 -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitDerived.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitDerived.json index f5cb1c2e0f..c1be1d2ba0 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitDerived.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitDerived.json @@ -13,4 +13,4 @@ "exponent" : 1.0, "unitBean" : "efb2d32a-42c4-4f33-820c-88a1e61ccfd0" } ] -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitLinearConversion.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitLinearConversion.json index e0153cc09d..b59ed2f0b8 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitLinearConversion.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitLinearConversion.json @@ -5,4 +5,4 @@ "quantityKindBean" : "cf277f96-e167-45a1-85f7-0470e9c85ecb", "symbol" : "byte", "factor" : 8.0 -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitPrefixed.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitPrefixed.json index 66d5481613..bee1f3ed19 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitPrefixed.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitPrefixed.json @@ -5,4 +5,4 @@ "quantityKindBean" : "882b2e01-712d-4557-bc25-3158cd4ff316", "symbol" : "km", "prefixBean" : "ca6c002a-b269-41b1-9afe-b805a30f8c29" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitSimple.json b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitSimple.json index e97e587a2e..76cdac6933 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitSimple.json +++ b/de.dlr.sc.virsat.model.extension.tests.test/resources/json/qudv/BeanUnitSimple.json @@ -4,4 +4,4 @@ "name" : "Meter", "quantityKindBean" : "882b2e01-712d-4557-bc25-3158cd4ff316", "symbol" : "m" -} \ No newline at end of file +} diff --git a/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/model/json/JsonTestHelper.java b/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/model/json/JsonTestHelper.java index 2f33a5221f..8c67c466f1 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/model/json/JsonTestHelper.java +++ b/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/model/json/JsonTestHelper.java @@ -9,7 +9,6 @@ *******************************************************************************/ package de.dlr.sc.virsat.model.extension.tests.model.json; -import static de.dlr.sc.virsat.model.extension.tests.test.TestActivator.assertEqualsNoWs; import java.io.IOException; import java.io.StringReader; @@ -51,6 +50,7 @@ import de.dlr.sc.virsat.model.dvlm.units.UnitsFactory; import de.dlr.sc.virsat.model.extension.tests.model.TestCategoryAllProperty; import de.dlr.sc.virsat.model.extension.tests.test.TestActivator; +import de.dlr.sc.virsat.test.utils.TestUtil; /** * Class containing static helper functions @@ -180,8 +180,7 @@ public static void assertMarshall(JAXBUtility jaxbUtility, String resource, Obje StringWriter sw = new StringWriter(); jsonMarshaller.marshal(testObject, sw); - String expectedJson = TestActivator.getResourceContentAsString(resource); - assertEqualsNoWs("Json is as expected", expectedJson, sw.toString()); + TestUtil.assertEqualContent(sw.toString(), TestActivator.FRAGMENT_ID, resource); } public static Unmarshaller getUnmarshaller(JAXBUtility jaxbUtility, EObject modelObject) throws JAXBException, IOException { diff --git a/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/test/TestActivator.java b/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/test/TestActivator.java index 9509dafb7b..c7a9966afc 100644 --- a/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/test/TestActivator.java +++ b/de.dlr.sc.virsat.model.extension.tests.test/src/de/dlr/sc/virsat/model/extension/tests/test/TestActivator.java @@ -9,17 +9,10 @@ *******************************************************************************/ package de.dlr.sc.virsat.model.extension.tests.test; -import java.io.BufferedReader; +import de.dlr.sc.virsat.test.utils.TestUtil; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; - -import org.junit.Assert; public class TestActivator { - - /** * Hidden construcotr of activator class */ @@ -35,34 +28,6 @@ private TestActivator() { * @throws IOException throws */ public static String getResourceContentAsString(String resourcePath) throws IOException { - URL url = new URL("platform:/plugin/" + FRAGMENT_ID + resourcePath); - InputStream inputStream = url.openConnection().getInputStream(); - - StringBuilder fileContent = new StringBuilder(); - try (BufferedReader in = new BufferedReader(new InputStreamReader(inputStream))) { - String inputLine; - - while ((inputLine = in.readLine()) != null) { - fileContent.append(inputLine); - fileContent.append(System.lineSeparator()); - } - } - - return fileContent.toString(); - } - - /** - * Assert a message after removing new line at end of file - * @param message - * @param expected - * @param actual - */ - public static void assertEqualsNoWs(String message, String expected, String actual) { - String expectedNoWs = expected.replaceAll("\\s+", ""); - String actualNoWs = actual.replaceAll("\\s+", ""); - - if (!expectedNoWs.equals(actualNoWs)) { - Assert.assertEquals(message, expected, actual); - } + return TestUtil.getResourceContentAsString(FRAGMENT_ID, resourcePath); } } diff --git a/de.dlr.sc.virsat.server.test/src/de/dlr/sc/virsat/server/resources/AModelAccessResourceTest.java b/de.dlr.sc.virsat.server.test/src/de/dlr/sc/virsat/server/resources/AModelAccessResourceTest.java index d45f2e6103..2ecd3f52f2 100644 --- a/de.dlr.sc.virsat.server.test/src/de/dlr/sc/virsat/server/resources/AModelAccessResourceTest.java +++ b/de.dlr.sc.virsat.server.test/src/de/dlr/sc/virsat/server/resources/AModelAccessResourceTest.java @@ -366,11 +366,13 @@ protected void testPutSei(IBeanStructuralElementInstance sei) throws Exception { protected void testPutProperty(IBeanObject property) throws Exception { int commits = VersionControlTestHelper.countCommits(testServerRepository.getLocalRepositoryPath()); + Entity entity = Entity.entity(property, MediaType.APPLICATION_JSON_TYPE); + Response response = webTarget .path(RepositoryAccessResource.PROPERTY) .request() .header(HttpHeaders.AUTHORIZATION, USER_WITH_REPO_HEADER) - .put(Entity.entity(property, MediaType.APPLICATION_JSON_TYPE)); + .put(entity); assertEquals(HttpStatus.OK_200, response.getStatus()); assertEquals("No new commit on put without changes", commits, diff --git a/de.dlr.sc.virsat.server/src/de/dlr/sc/virsat/server/repository/ServerRepoHelper.java b/de.dlr.sc.virsat.server/src/de/dlr/sc/virsat/server/repository/ServerRepoHelper.java index cb23debe29..43aa2af548 100644 --- a/de.dlr.sc.virsat.server/src/de/dlr/sc/virsat/server/repository/ServerRepoHelper.java +++ b/de.dlr.sc.virsat.server/src/de/dlr/sc/virsat/server/repository/ServerRepoHelper.java @@ -45,7 +45,7 @@ public static void initRepoRegistry() throws IOException { Files.createDirectories(serverConfigurationDirectory); } - Activator.getDefault().getLog().info("Searching for repositories in: " + serverConfigurationDirectory); + Activator.getDefault().getLog().info("Searching for repositories in: " + serverConfigurationDirectory.toAbsolutePath()); Files.walk(serverConfigurationDirectory) .filter(Files::isRegularFile) .forEach(potentialConfigFile -> { diff --git a/de.dlr.sc.virsat.test.feature/feature.xml b/de.dlr.sc.virsat.test.feature/feature.xml index dd0f9db8c8..19812dfd4e 100644 --- a/de.dlr.sc.virsat.test.feature/feature.xml +++ b/de.dlr.sc.virsat.test.feature/feature.xml @@ -1,14 +1,20 @@ - + + - DLR SC VirSat Tests Feature -German Aerospace Center (DLR e.V.) + DLR SC VirSat Tests Feature +German Aerospace Center (DLR e.V.) Simulation and Software Technology - Copyright 2015 - + Copyright 2015 + by German Aerospace Center (DLR e.V.) @@ -16,132 +22,212 @@ by German Aerospace Center (DLR e.V.) %license - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - \ No newline at end of file + diff --git a/de.dlr.sc.virsat.test.utils/.checkstyle b/de.dlr.sc.virsat.test.utils/.checkstyle new file mode 100644 index 0000000000..18174367fb --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.checkstyle @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/de.dlr.sc.virsat.test.utils/.classpath b/de.dlr.sc.virsat.test.utils/.classpath new file mode 100644 index 0000000000..8d8612144f --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/de.dlr.sc.virsat.test.utils/.project b/de.dlr.sc.virsat.test.utils/.project new file mode 100644 index 0000000000..c490c98b1e --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.project @@ -0,0 +1,36 @@ + + + de.dlr.sc.virsat.test.utils + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + net.sf.eclipsecs.core.CheckstyleBuilder + + + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature + + diff --git a/de.dlr.sc.virsat.test.utils/.settings/edu.umd.cs.findbugs.core.prefs b/de.dlr.sc.virsat.test.utils/.settings/edu.umd.cs.findbugs.core.prefs new file mode 100644 index 0000000000..eaaad8dbb0 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/edu.umd.cs.findbugs.core.prefs @@ -0,0 +1,144 @@ +#SpotBugs User Preferences +#Tue Jan 21 14:54:00 CET 2020 +detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true +detectorAtomicityProblem=AtomicityProblem|true +detectorBadAppletConstructor=BadAppletConstructor|false +detectorBadResultSetAccess=BadResultSetAccess|true +detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true +detectorBadUseOfReturnValue=BadUseOfReturnValue|true +detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true +detectorBooleanReturnNull=BooleanReturnNull|true +detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false +detectorCheckExpectedWarnings=CheckExpectedWarnings|false +detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true +detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true +detectorCheckTypeQualifiers=CheckTypeQualifiers|true +detectorCloneIdiom=CloneIdiom|true +detectorComparatorIdiom=ComparatorIdiom|true +detectorConfusedInheritance=ConfusedInheritance|true +detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true +detectorCovariantArrayAssignment=CovariantArrayAssignment|false +detectorCrossSiteScripting=CrossSiteScripting|true +detectorDefaultEncodingDetector=DefaultEncodingDetector|true +detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true +detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true +detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true +detectorDontUseEnum=DontUseEnum|true +detectorDroppedException=DroppedException|true +detectorDumbMethodInvocations=DumbMethodInvocations|true +detectorDumbMethods=DumbMethods|true +detectorDuplicateBranches=DuplicateBranches|true +detectorEmptyZipFileEntry=EmptyZipFileEntry|false +detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true +detectorExplicitSerialization=ExplicitSerialization|true +detectorFinalizerNullsFields=FinalizerNullsFields|true +detectorFindBadCast2=FindBadCast2|true +detectorFindBadForLoop=FindBadForLoop|true +detectorFindCircularDependencies=FindCircularDependencies|false +detectorFindComparatorProblems=FindComparatorProblems|true +detectorFindDeadLocalStores=FindDeadLocalStores|true +detectorFindDoubleCheck=FindDoubleCheck|true +detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true +detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true +detectorFindFinalizeInvocations=FindFinalizeInvocations|true +detectorFindFloatEquality=FindFloatEquality|true +detectorFindHEmismatch=FindHEmismatch|true +detectorFindInconsistentSync2=FindInconsistentSync2|true +detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true +detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true +detectorFindMaskedFields=FindMaskedFields|true +detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true +detectorFindNakedNotify=FindNakedNotify|true +detectorFindNonShortCircuit=FindNonShortCircuit|true +detectorFindNullDeref=FindNullDeref|true +detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true +detectorFindOpenStream=FindOpenStream|true +detectorFindPuzzlers=FindPuzzlers|true +detectorFindRefComparison=FindRefComparison|true +detectorFindReturnRef=FindReturnRef|true +detectorFindRoughConstants=FindRoughConstants|true +detectorFindRunInvocations=FindRunInvocations|true +detectorFindSelfComparison=FindSelfComparison|true +detectorFindSelfComparison2=FindSelfComparison2|true +detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true +detectorFindSpinLoop=FindSpinLoop|true +detectorFindSqlInjection=FindSqlInjection|true +detectorFindTwoLockWait=FindTwoLockWait|true +detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true +detectorFindUnconditionalWait=FindUnconditionalWait|true +detectorFindUninitializedGet=FindUninitializedGet|true +detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true +detectorFindUnreleasedLock=FindUnreleasedLock|true +detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true +detectorFindUnsyncGet=FindUnsyncGet|true +detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true +detectorFindUselessControlFlow=FindUselessControlFlow|true +detectorFindUselessObjects=FindUselessObjects|true +detectorFormatStringChecker=FormatStringChecker|true +detectorHugeSharedStringConstants=HugeSharedStringConstants|true +detectorIDivResultCastToDouble=IDivResultCastToDouble|true +detectorIncompatMask=IncompatMask|true +detectorInconsistentAnnotations=InconsistentAnnotations|true +detectorInefficientIndexOf=InefficientIndexOf|false +detectorInefficientInitializationInsideLoop=InefficientInitializationInsideLoop|false +detectorInefficientMemberAccess=InefficientMemberAccess|false +detectorInefficientToArray=InefficientToArray|false +detectorInfiniteLoop=InfiniteLoop|true +detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true +detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true +detectorInitializationChain=InitializationChain|true +detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true +detectorInstantiateStaticClass=InstantiateStaticClass|true +detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true +detectorInvalidJUnitTest=InvalidJUnitTest|true +detectorIteratorIdioms=IteratorIdioms|true +detectorLazyInit=LazyInit|true +detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true +detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true +detectorMethodReturnCheck=MethodReturnCheck|true +detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true +detectorMutableEnum=MutableEnum|true +detectorMutableLock=MutableLock|true +detectorMutableStaticFields=MutableStaticFields|true +detectorNaming=Naming|true +detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true +detectorNumberConstructor=NumberConstructor|true +detectorOptionalReturnNull=OptionalReturnNull|true +detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true +detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true +detectorPublicSemaphores=PublicSemaphores|false +detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true +detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true +detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true +detectorRedundantConditions=RedundantConditions|true +detectorRedundantInterfaces=RedundantInterfaces|true +detectorRepeatedConditionals=RepeatedConditionals|true +detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true +detectorSerializableIdiom=SerializableIdiom|true +detectorStartInConstructor=StartInConstructor|true +detectorStaticCalendarDetector=StaticCalendarDetector|true +detectorStringConcatenation=StringConcatenation|true +detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true +detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true +detectorSwitchFallthrough=SwitchFallthrough|true +detectorSynchronizationOnSharedBuiltinConstant=SynchronizationOnSharedBuiltinConstant|true +detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true +detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true +detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true +detectorURLProblems=URLProblems|true +detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true +detectorUnnecessaryMath=UnnecessaryMath|true +detectorUnreadFields=UnreadFields|true +detectorUselessSubclassMethod=UselessSubclassMethod|false +detectorVarArgsProblems=VarArgsProblems|true +detectorVolatileUsage=VolatileUsage|true +detectorWaitInLoop=WaitInLoop|true +detectorWrongMapIterator=WrongMapIterator|true +detectorXMLFactoryBypass=XMLFactoryBypass|true +detector_threshold=2 +effort=default +excludefilter0=../spotbugs-exclude.xml|true +filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false|20 +filter_settings_neg=MALICIOUS_CODE,SECURITY,EXPERIMENTAL,NOISE,I18N| +includefilter0=../spotbugs-include.xml|true +run_at_full_build=false diff --git a/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.resources.prefs b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.runtime.prefs b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..deae05a977 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.jdt.core.prefs b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..d4540a53f9 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.m2e.core.prefs b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000..f897a7f1cb --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.mylyn.team.ui.prefs b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.mylyn.team.ui.prefs new file mode 100644 index 0000000000..426f180206 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/.settings/org.eclipse.mylyn.team.ui.prefs @@ -0,0 +1,2 @@ +commit.comment.template=Write a Heading here - (Task \#${task.key})\r\n\r\nPut your Message here.\r\n\r\n---\r\nTask \#${task.key}\: ${task.description} +eclipse.preferences.version=1 diff --git a/de.dlr.sc.virsat.test.utils/META-INF/MANIFEST.MF b/de.dlr.sc.virsat.test.utils/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6eee74f9d8 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: VirSat Test Utils +Bundle-SymbolicName: de.dlr.sc.virsat.test.utils +Bundle-Version: 4.18.0.qualifier +Bundle-Activator: de.dlr.sc.virsat.test.utils.Activator +Bundle-Vendor: DLR (German Aerospace Center) +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources, + org.junit +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy +Eclipse-ExtensibleAPI: true +Export-Package: de.dlr.sc.virsat.test.utils +Automatic-Module-Name: de.dlr.sc.virsat.test.utils diff --git a/de.dlr.sc.virsat.test.utils/about.html b/de.dlr.sc.virsat.test.utils/about.html new file mode 100644 index 0000000000..39cd6411ff --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/about.html @@ -0,0 +1,27 @@ + + + + +About + + +

About This Content

+ +

December 18, 2018

+

License

+ +

The German Aerospace Center (DLR) makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is available +at https://www.eclipse.org/legal/epl-2.0. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from German Aerospace Center (DLR), the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to this content.

+ + + diff --git a/de.dlr.sc.virsat.test.utils/build.properties b/de.dlr.sc.virsat.test.utils/build.properties new file mode 100644 index 0000000000..dff841f70e --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + resources/,\ + about.html diff --git a/de.dlr.sc.virsat.test.utils/pom.xml b/de.dlr.sc.virsat.test.utils/pom.xml new file mode 100644 index 0000000000..d7a8040393 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/pom.xml @@ -0,0 +1,23 @@ + + + + + de.dlr.sc.virsat.parent + de.dlr.sc.virsat + 4.18.0-SNAPSHOT + ../maven/pom.xml + + 4.0.0 + de.dlr.sc.virsat.test.utils + de.dlr.sc.virsat.test.utils + eclipse-plugin + \ No newline at end of file diff --git a/de.dlr.sc.virsat.test.utils/resources/.empty b/de.dlr.sc.virsat.test.utils/resources/.empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/Activator.java b/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/Activator.java new file mode 100644 index 0000000000..351311ef5d --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/Activator.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2008-2019 German Aerospace Center (DLR), Simulation and Software Technology, Germany. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package de.dlr.sc.virsat.test.utils; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + + +/** + * the activator is the entry point for this plugin + */ +public class Activator extends Plugin { + + private static String pluginId; + private static Activator plugin; + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + Activator.pluginId = getDefault().getBundle().getSymbolicName(); + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + public static Activator getDefault() { + return plugin; + } + + public static String getPluginId() { + return pluginId; + } + + +} diff --git a/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/TestUtil.java b/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/TestUtil.java new file mode 100644 index 0000000000..b03cd92118 --- /dev/null +++ b/de.dlr.sc.virsat.test.utils/src/de/dlr/sc/virsat/test/utils/TestUtil.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2008-2019 German Aerospace Center (DLR), Simulation and Software Technology, Germany. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package de.dlr.sc.virsat.test.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; + +import org.junit.Assert; + +public class TestUtil { + + private TestUtil() { + } + + /** + * Set this flag to output the actual content to the console + */ + + private static final String ENV_VARIABLE_FLUSH_ACTUAL = "flushActualGeneratorFiles"; + private static final String ENV_VARIABLE_FLUSH_ACTUAL_TRUE = "true"; + private static final String ENV_VARIABLE_FLUSH_PATH = "flushActualPath"; + + + /** + * Method to check content against a reference from the resources folder + * @param actual the current content as string + * @param expectedFilePath the path to the file containing the expected content + * @throws IOException in case the expected content file could not be read + */ + public static void assertEqualContent(String actual, String fragementId, String expectedFilePath) throws IOException { + + if (ENV_VARIABLE_FLUSH_ACTUAL_TRUE.equalsIgnoreCase(System.getenv(ENV_VARIABLE_FLUSH_ACTUAL))) { + String fileName = System.getenv(ENV_VARIABLE_FLUSH_PATH) + expectedFilePath.substring(expectedFilePath.lastIndexOf('/'), expectedFilePath.length()); + + PrintWriter writer = new PrintWriter(fileName, "UTF-8"); + writer.println(actual); + writer.close(); + return; + } + + String expectedString = getResourceContentAsString(fragementId, expectedFilePath); + String expectedNoWs = expectedString.replaceAll("\\s+", ""); + String actualNoWs = actual.replaceAll("\\s+", ""); + + if (!expectedNoWs.equals(actualNoWs)) { + Assert.assertEquals("File content for " + expectedFilePath + " is correct", expectedString, actual); + } + } + + /** + * Method to access the fragments contents from the resource folder and to hand it back as string + * @param resourcePath the path to the resource starting with "resource/" + * @return the content of the resource as string + * @throws IOException throws + */ + public static String getResourceContentAsString(String fragmentId, String resourcePath) throws IOException { + URL url = new URL("platform:/plugin/" + fragmentId + resourcePath); + InputStream inputStream = url.openConnection().getInputStream(); + + StringBuilder fileContent = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(inputStream))) { + String inputLine; + + while ((inputLine = in.readLine()) != null) { + fileContent.append(inputLine); + fileContent.append(System.lineSeparator()); + } + } + + return fileContent.toString(); + } +} diff --git a/launchers/VirSat Headless Server.launch b/launchers/VirSat Headless Server.launch index 167f01ee43..76164cd28d 100644 --- a/launchers/VirSat Headless Server.launch +++ b/launchers/VirSat Headless Server.launch @@ -64,7 +64,10 @@ + + + @@ -83,7 +86,11 @@ + + + + diff --git a/pom.xml b/pom.xml index ce169383da..feba9dafc4 100644 --- a/pom.xml +++ b/pom.xml @@ -133,6 +133,7 @@ de.dlr.sc.virsat.server.swagger.ui de.dlr.sc.virsat.concept.unittest.util + de.dlr.sc.virsat.test.utils de.dlr.sc.virsat.test de.dlr.sc.virsat.model.extension.thermal