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 Classes
    Modifier and Type
    Class
    Description
    private static class 
    A 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

    Fields
    Modifier and Type
    Field
    Description
    private static File
     
    private static final String
     
    private static File
     
    private static File
     
    private static File
     
    private static String
     
    private static Set<String>
     

    Fields inherited from class test.de.iip_ecosphere.platform.support.TestWithPlugin

    PROP_AAS_PLUGIN
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    assertBooleanVar(boolean expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Asserts that var has the expected Boolean value.
    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)
    Asserts a graph mesh.
    private void
    assertIntVar(int expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Asserts that var has the expected Boolean value.
    private void
    assertIvmlFileChange(String file, boolean invert, String... expected)
    Very simple check that an IVML file was changed and contains expected strings.
    private void
    assertStringVar(String expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Asserts that var has the expected String value.
    private String
    assertSubmodel(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 void
    assertVariableName(String variableName)
    Asserts the validity of a variable name, stores it internally and tries to figure out, whether repeated ones were created.
    private static void
    copy(String baseFolder, String... fileNames)
    Copies files given by their simple names within the same baseFolder into ivmlFolder.
    private de.iip_ecosphere.platform.configuration.ivml.AasIvmlMapper
    getInstance(boolean adapt)
    Creates a mapper instance.
    void
    Tests instantiating a template AbstractIvmlModifier.getOpenTemplateVariables(String).
    private File
    Composes an (expected) IVML file name.
    void
    Sets up the tests.
    private static void
    Creates/cleans a temporary folder and copies the needed IVML files for testing.
    void
    Cleans up after the tests.
    private de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor
    startEasy(de.iip_ecosphere.platform.configuration.PlatformInstantiator.InstantiationConfigurer configurer)
    Starts EASy using an instantiation configurer.
    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.
    private void
    stopEasy(de.iip_ecosphere.platform.configuration.ConfigurationLifecycleDescriptor lcd)
    Stops EASy using an instantiation configurer.
    void
    Tests AasIvmlMapper.
    void
    Tests the set/delete graph functions.
    void
    Tests AbstractIvmlModifier.changeValues(java.util.Map).
    void
    Tests the create/delete variable function.
    void
    Tests AbstractIvmlModifier.getTemplates().
    void
    Tests AbstractIvmlModifier.getVariable(String).
    void
    Tests AbstractIvmlModifier.getVariableName(String, String, String).
    void
    Tests instantiating a template AbstractIvmlModifier.getOpenTemplateVariables(String).
    void
    Tests renaming a variable using AbstractIvmlModifier.renameVariable(String, String).

    Methods inherited from class test.de.iip_ecosphere.platform.support.aas.TestWithPlugin

    setAasPluginId, setupAASPlugins

    Methods inherited from class test.de.iip_ecosphere.platform.support.TestWithPlugin

    addPluginLocation, addRunAfterLoading, clear, enableLocalPlugins, loadPlugins, setInstallDir

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MODEL_NAME

      private static final String MODEL_NAME
      See Also:
    • ivmlFolder

      private static File ivmlFolder
    • origBase

      private static File origBase
    • origIvmlMeta

      private static File origIvmlMeta
    • origIvmlConfig

      private static File origIvmlConfig
    • origIvmlModelName

      private static String origIvmlModelName
    • varNames

      private static Set<String> varNames
  • Constructor Details

    • AasIvmlMapperTest

      public AasIvmlMapperTest()
  • Method Details

    • setup

      public void setup()
      Sets up the tests.
      Overrides:
      setup in class test.de.iip_ecosphere.platform.support.aas.TestWithPlugin
    • setupIvmlFiles

      private static void setupIvmlFiles() throws IOException
      Creates/cleans a temporary folder and copies the needed IVML files for testing.
      Throws:
      IOException - if copying fails
    • copy

      private static void copy(String baseFolder, String... fileNames) throws IOException
      Copies files given by their simple names within the same baseFolder into ivmlFolder.
      Parameters:
      baseFolder - the base folder
      fileNames - the file names
      Throws:
      IOException - if copying fails
    • shutdown

      public void shutdown()
      Cleans up after the tests.
    • testAasIvmlMapper

      public void testAasIvmlMapper() throws ExecutionException
      Tests AasIvmlMapper.
      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 model
      appName - the name of the app to assert/use
      netIndex - the 0-based index of the service net to assert
      servicesAsserter - generic services asserter
      format - 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. Call startEasy(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 instance
      appName - the name of the app to assert/use
      netIndex - the 0-based index of the service net to assert
      servicesAsserter - generic services asserter
      Returns:
      the graph as String representation
      Throws:
      ExecutionException - shall not occur in a successful test
    • testGetVariable

      public void testGetVariable() throws ExecutionException
      Tests AbstractIvmlModifier.getVariable(String).
      Throws:
      ExecutionException - shall not occur if successful
    • testChangeValues

      public void testChangeValues() throws ExecutionException, IOException
      Tests AbstractIvmlModifier.changeValues(java.util.Map).
      Throws:
      ExecutionException - shall not occur if successful
      IOException - if resetting IVML files fails
    • testChangeGraph

      public void testChangeGraph() throws IOException, ExecutionException
      Tests the set/delete graph functions.
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if setting graphs fails
    • testCreateDeleteVariable

      public void testCreateDeleteVariable() throws IOException, ExecutionException
      Tests the create/delete variable function.
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if creating/deleting the variable fails
    • testGetTemplates

      public void testGetTemplates() throws IOException, ExecutionException
      Tests AbstractIvmlModifier.getTemplates().
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if the operation fails
    • testRenameVariable

      public void testRenameVariable() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryException
      Tests renaming a variable using AbstractIvmlModifier.renameVariable(String, String).
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if the operation fails
      net.ssehub.easy.varModel.model.ModelQueryException - if accessing IVML parts fails
    • testInstantiateTemplate

      public void testInstantiateTemplate() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryException
      Tests instantiating a template AbstractIvmlModifier.getOpenTemplateVariables(String).
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if the operation fails
      net.ssehub.easy.varModel.model.ModelQueryException - if accessing IVML parts fails
    • getOpenTemplateVariables

      public void getOpenTemplateVariables() throws IOException, ExecutionException, net.ssehub.easy.varModel.model.ModelQueryException
      Tests instantiating a template AbstractIvmlModifier.getOpenTemplateVariables(String).
      Throws:
      IOException - if copying/resetting files fails
      ExecutionException - if the operation fails
      net.ssehub.easy.varModel.model.ModelQueryException - if accessing IVML parts fails
    • assertStringVar

      private void assertStringVar(String expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Asserts that var has the expected String value.
      Parameters:
      expected - the expected value
      var - the variable
    • assertBooleanVar

      private void assertBooleanVar(boolean expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Asserts that var has the expected Boolean value.
      Parameters:
      expected - the expected value
      var - the variable
    • assertIntVar

      private void assertIntVar(int expected, net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Asserts that var has the expected Boolean value.
      Parameters:
      expected - the expected value
      var - the variable
    • resolveIvmlFile

      private File resolveIvmlFile(String file)
      Composes an (expected) IVML file name.
      Parameters:
      file - the file name, may contain paths
      Returns:
      the file object
    • assertIvmlFileChange

      private void assertIvmlFileChange(String file, boolean invert, String... expected)
      Very simple check that an IVML file was changed and contains expected strings.
      Parameters:
      file - the file to check, within #ivmlFolder
      invert - if false assert for existence, if true for absence
      expected - the expected strings
    • testGetVariableName

      public void testGetVariableName()
      Tests AbstractIvmlModifier.getVariableName(String, String, String).
    • assertVariableName

      private static void assertVariableName(String variableName)
      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