Class PersistenceTest


  • public abstract class PersistenceTest
    extends java.lang.Object
    Tests PersistenceRecipe. This class only implements the basics and must be completed by the respective AAS abstraction implementation.
    Author:
    Holger Eichelberger, SSE
    • Constructor Summary

      Constructors 
      Constructor Description
      PersistenceTest()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private static void assertAas​(java.util.List<de.iip_ecosphere.platform.support.aas.Aas> aasIn, boolean justFirst, boolean testAsset)
      Asserts the expected contents in read AAS.
      protected abstract boolean assertAsset​(java.io.File file)
      Returns whether the asset/properties shall be asserted.
      protected abstract boolean assertOnlyFirst​(java.io.File file)
      Returns whether only the first AAS shall be asserted.
      protected abstract java.io.File[] filesToTest()
      Returns the files to test.
      protected static java.io.File obtainTmpFile​(java.lang.String name)
      Obtains the name of a file in the temporary directory and tries to ensure that it does not exist.
      protected abstract java.util.List<de.iip_ecosphere.platform.support.aas.Aas> selectedAas​(java.io.File file, java.util.List<de.iip_ecosphere.platform.support.aas.Aas> aas)
      Returns the AAS to test, as a selection of aas.
      void testWriteRead()
      Tests writing/reading.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PersistenceTest

        public PersistenceTest()
    • Method Detail

      • testWriteRead

        public void testWriteRead()
                           throws java.io.IOException
        Tests writing/reading.
        Throws:
        java.io.IOException - shall not occur
      • filesToTest

        protected abstract java.io.File[] filesToTest()
        Returns the files to test.
        Returns:
        the files to test
      • selectedAas

        protected abstract java.util.List<de.iip_ecosphere.platform.support.aas.Aas> selectedAas​(java.io.File file,
                                                                                                 java.util.List<de.iip_ecosphere.platform.support.aas.Aas> aas)
        Returns the AAS to test, as a selection of aas. This may be required if a certain persistence recipe does not take multiple AAS.
        Parameters:
        file - the file to write as an indicator of the current test process, one of the files from filesToTest()
        aas - the AAS to select from (unmodifiable)
        Returns:
        the selected AAS
      • assertOnlyFirst

        protected abstract boolean assertOnlyFirst​(java.io.File file)
        Returns whether only the first AAS shall be asserted. This may be required if selectedAas(File, List) selects AAS.
        Parameters:
        file - the file to write as an indicator of the current test process, one of the files from filesToTest()
        Returns:
        true for asserting only the first, false for asserting all
      • assertAsset

        protected abstract boolean assertAsset​(java.io.File file)
        Returns whether the asset/properties shall be asserted.
        Parameters:
        file - the file to write as an indicator of the current test process, one of the files from filesToTest()
        Returns:
        true for asserting the asset/properties, false for ignoring the asset
      • obtainTmpFile

        protected static java.io.File obtainTmpFile​(java.lang.String name)
        Obtains the name of a file in the temporary directory and tries to ensure that it does not exist. We go for file names so that debugging becomes possible (rather than for random names).
        Parameters:
        name - the name of the file
        Returns:
        the file
      • assertAas

        private static void assertAas​(java.util.List<de.iip_ecosphere.platform.support.aas.Aas> aasIn,
                                      boolean justFirst,
                                      boolean testAsset)
        Asserts the expected contents in read AAS.
        Parameters:
        aasIn - the input/read AAS
        justFirst - consider only the first AAS
        testAsset - consider the asset during testing