Class AasIvmlMapperTest
java.lang.Object
test.de.iip_ecosphere.platform.support.TestWithPlugin
test.de.iip_ecosphere.platform.support.aas.TestWithPlugin
test.de.iip_ecosphere.platform.configuration.AasIvmlMapperTest
public class AasIvmlMapperTest
extends test.de.iip_ecosphere.platform.support.aas.TestWithPlugin
Tests
AasIvmlMapper.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA slightly extended graph mapper that changes an extended managed model structure with wildcards for AllTypes and AllServices into the usual structure while modifying a graph. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Fileprivate static final Stringprivate static Fileprivate static Fileprivate static Fileprivate static StringFields inherited from class test.de.iip_ecosphere.platform.support.TestWithPlugin
PROP_AAS_PLUGIN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidassertBooleanVar(boolean expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedBoolean value.private de.iip_ecosphere.platform.configuration.ivml.IvmlGraphMapper.IvmlGraphassertGraphMesh(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer, String appName, int netIndex, Consumer<de.iip_ecosphere.platform.support.aas.SubmodelElementCollection> servicesAsserter, de.iip_ecosphere.platform.configuration.ivml.GraphFormat format) Asserts a graph mesh.private voidassertIntVar(int expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedBoolean value.private voidassertIvmlFileChange(String file, boolean invert, String... expected) Very simple check that an IVML file was changed and contains expected strings.private voidassertStringVar(String expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedString value.private StringassertSubmodel(de.iip_ecosphere.platform.support.aas.Submodel sm, String appName, int netIndex, Consumer<de.iip_ecosphere.platform.support.aas.SubmodelElementCollection> servicesAsserter) Asserts the simple mesh configuration submodel.private static voidassertVariableName(String variableName) Asserts the validity of a variable name, stores it internally and tries to figure out, whether repeated ones were created.private static voidCopies files given by their simple names within the samebaseFolderintoivmlFolder.private de.iip_ecosphere.platform.configuration.ivml.AasIvmlMappergetInstance(boolean adapt) Creates a mapper instance.voidTests instantiating a templateAbstractIvmlModifier.getOpenTemplateVariables(String).private FileresolveIvmlFile(String file) Composes an (expected) IVML file name.voidsetup()Sets up the tests.private static voidCreates/cleans a temporary folder and copies the needed IVML files for testing.voidshutdown()Cleans up after the tests.private de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptorstartEasy(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer) Starts EASy using an instantiation configurer.private de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptorstartEasyValidate(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer) Starts EASy using an instantiation configurer and validates/asserts the model.private voidstopEasy(de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor lcd) Stops EASy using an instantiation configurer.voidTestsAasIvmlMapper.voidTests the set/delete graph functions.voidTestsAbstractIvmlModifier.changeValues(java.util.Map).voidTests the create/delete variable function.voidTestsAbstractIvmlModifier.getTemplates().voidTestsAbstractIvmlModifier.getVariable(String).voidTestsAbstractIvmlModifier.getVariableName(String, String, String).voidTests instantiating a templateAbstractIvmlModifier.getOpenTemplateVariables(String).voidTests renaming a variable usingAbstractIvmlModifier.renameVariable(String, String).Methods inherited from class test.de.iip_ecosphere.platform.support.aas.TestWithPlugin
setAasPluginId, setupAASPluginsMethods inherited from class test.de.iip_ecosphere.platform.support.TestWithPlugin
addPluginLocation, addRunAfterLoading, clear, enableLocalPlugins, loadPlugins, setInstallDir
-
Field Details
-
MODEL_NAME
- See Also:
-
ivmlFolder
-
origBase
-
origIvmlMeta
-
origIvmlConfig
-
origIvmlModelName
-
varNames
-
-
Constructor Details
-
AasIvmlMapperTest
public AasIvmlMapperTest()
-
-
Method Details
-
setup
public void setup()Sets up the tests.- Overrides:
setupin classtest.de.iip_ecosphere.platform.support.aas.TestWithPlugin
-
setupIvmlFiles
Creates/cleans a temporary folder and copies the needed IVML files for testing.- Throws:
IOException- if copying fails
-
copy
Copies files given by their simple names within the samebaseFolderintoivmlFolder.- Parameters:
baseFolder- the base folderfileNames- the file names- Throws:
IOException- if copying fails
-
shutdown
public void shutdown()Cleans up after the tests. -
testAasIvmlMapper
TestsAasIvmlMapper.- Throws:
ExecutionException- shall not occur in a successful test
-
startEasy
private de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor startEasy(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer) Starts EASy using an instantiation configurer.- Parameters:
configurer- the configurer- Returns:
- the configuration lifecycle descriptor
-
startEasyValidate
private de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor startEasyValidate(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer) Starts EASy using an instantiation configurer and validates/asserts the model.- Parameters:
configurer- the configurer- Returns:
- the configuration lifecycle descriptor
-
stopEasy
private void stopEasy(de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor lcd) Stops EASy using an instantiation configurer.- Parameters:
lcd- the configuration lifecycle descriptor
-
assertGraphMesh
private de.iip_ecosphere.platform.configuration.ivml.IvmlGraphMapper.IvmlGraph assertGraphMesh(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer, String appName, int netIndex, Consumer<de.iip_ecosphere.platform.support.aas.SubmodelElementCollection> servicesAsserter, de.iip_ecosphere.platform.configuration.ivml.GraphFormat format) throws ExecutionException Asserts a graph mesh.- Parameters:
configurer- the instantiation configurer allowing to read an IVML modelappName- the name of the app to assert/usenetIndex- the 0-based index of the service net to assertservicesAsserter- generic services asserterformat- the graph format to use- Returns:
- the graph as internal representation
- Throws:
ExecutionException- shall not occur in a successful test
-
getInstance
private de.iip_ecosphere.platform.configuration.ivml.AasIvmlMapper getInstance(boolean adapt) Creates a mapper instance. CallstartEasy(InstantiationConfigurer)or#startEasyValidate(InstantiationConfigurer)before.- Parameters:
adapt- allow for adaptation/rewriting of the model structure from an extended managed model to a default managed model- Returns:
- the instance
-
assertSubmodel
private String assertSubmodel(de.iip_ecosphere.platform.support.aas.Submodel sm, String appName, int netIndex, Consumer<de.iip_ecosphere.platform.support.aas.SubmodelElementCollection> servicesAsserter) throws ExecutionException Asserts the simple mesh configuration submodel.- Parameters:
sm- the submodel instanceappName- the name of the app to assert/usenetIndex- the 0-based index of the service net to assertservicesAsserter- generic services asserter- Returns:
- the graph as String representation
- Throws:
ExecutionException- shall not occur in a successful test
-
testGetVariable
TestsAbstractIvmlModifier.getVariable(String).- Throws:
ExecutionException- shall not occur if successful
-
testChangeValues
TestsAbstractIvmlModifier.changeValues(java.util.Map).- Throws:
ExecutionException- shall not occur if successfulIOException- if resetting IVML files fails
-
testChangeGraph
Tests the set/delete graph functions.- Throws:
IOException- if copying/resetting files failsExecutionException- if setting graphs fails
-
testCreateDeleteVariable
Tests the create/delete variable function.- Throws:
IOException- if copying/resetting files failsExecutionException- if creating/deleting the variable fails
-
testGetTemplates
TestsAbstractIvmlModifier.getTemplates().- Throws:
IOException- if copying/resetting files failsExecutionException- if the operation fails
-
testRenameVariable
public void testRenameVariable() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryExceptionTests renaming a variable usingAbstractIvmlModifier.renameVariable(String, String).- Throws:
IOException- if copying/resetting files failsExecutionException- if the operation failsnet.ssehub.easy.varModel.model.ModelQueryException- if accessing IVML parts fails
-
testInstantiateTemplate
public void testInstantiateTemplate() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryExceptionTests instantiating a templateAbstractIvmlModifier.getOpenTemplateVariables(String).- Throws:
IOException- if copying/resetting files failsExecutionException- if the operation failsnet.ssehub.easy.varModel.model.ModelQueryException- if accessing IVML parts fails
-
getOpenTemplateVariables
public void getOpenTemplateVariables() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryExceptionTests instantiating a templateAbstractIvmlModifier.getOpenTemplateVariables(String).- Throws:
IOException- if copying/resetting files failsExecutionException- if the operation failsnet.ssehub.easy.varModel.model.ModelQueryException- if accessing IVML parts fails
-
assertStringVar
private void assertStringVar(String expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedString value.- Parameters:
expected- the expected valuevar- the variable
-
assertBooleanVar
private void assertBooleanVar(boolean expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedBoolean value.- Parameters:
expected- the expected valuevar- the variable
-
assertIntVar
private void assertIntVar(int expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var) Asserts thatvarhas theexpectedBoolean value.- Parameters:
expected- the expected valuevar- the variable
-
resolveIvmlFile
Composes an (expected) IVML file name.- Parameters:
file- the file name, may contain paths- Returns:
- the file object
-
assertIvmlFileChange
Very simple check that an IVML file was changed and contains expected strings.- Parameters:
file- the file to check, within#ivmlFolderinvert- iffalseassert for existence, iftruefor absenceexpected- the expected strings
-
testGetVariableName
public void testGetVariableName()TestsAbstractIvmlModifier.getVariableName(String, String, String). -
assertVariableName
Asserts the validity of a variable name, stores it internally and tries to figure out, whether repeated ones were created.- Parameters:
variableName- the variable name to assert
-