Class AbstractEnvironmentTest

java.lang.Object
test.de.iip_ecosphere.platform.services.environment.AbstractEnvironmentTest
Direct Known Subclasses:
JavaEnvironmentTest, PythonEnvironmentSuiteTest, PythonEnvironmentTest

public abstract class AbstractEnvironmentTest extends Object
The common test code for all environments. Maximize code here rather than in specific environment tests.
Author:
Holger Eichelberger, SSE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static void
    assertOperation(de.iip_ecosphere.platform.support.aas.Submodel submodel, String operationName, Function<String,Boolean> cond, Function<Exception,Boolean> exc, Object... args)
    Asserts an operation invocation result through JsonResultWrapper.fromJson(Object).
    private static void
    assertProperty(de.iip_ecosphere.platform.support.aas.Submodel submodel, String propertyName, Function<Object,Boolean> cond)
    Asserts a property/value.
    private static boolean
    Checks whether obj is a boolean.
    private static boolean
    checkBoolean(Object obj, boolean expectedValue)
    Checks whether obj is a boolean with expectedValue.
    private static boolean
    Checks whether obj is an empty string.
    private static boolean
    checkKindString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceKind expectedValue)
    Checks whether obj is a string representing a value of ServiceKind.
    private static boolean
    Checks whether obj is a non-empty string.
    private static boolean
    Checks whether obj is a string representing a value of ServiceState.
    private static boolean
    checkStateString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceState expectedValue)
    Checks whether obj is a string representing a value of ServiceState.
    private static boolean
    checkString(Object obj, String expected)
    Checks whether obj is a non-empty string.
    private static boolean
    checkVersion(Object obj, de.iip_ecosphere.platform.support.Version expected)
    Checks whether the given obj complies with the expected version.
    static void
    testAas(de.iip_ecosphere.platform.support.aas.SetupSpec spec, de.iip_ecosphere.platform.services.environment.Service expected)
    Tests the agreed AAS behavior created by AasCreator.
    static void
    testAasResult(AasCreator.AasResult result, de.iip_ecosphere.platform.services.environment.Service expected)
    Does further tests based on the given result instance.

    Methods inherited from class java.lang.Object

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

    • AbstractEnvironmentTest

      public AbstractEnvironmentTest()
  • Method Details

    • testAas

      public static void testAas(de.iip_ecosphere.platform.support.aas.SetupSpec spec, de.iip_ecosphere.platform.services.environment.Service expected) throws IOException, ExecutionException
      Tests the agreed AAS behavior created by AasCreator.
      Parameters:
      spec - the setup specification
      expected - expected service (with values)
      Throws:
      IOException - if accessing the AAS fails
      ExecutionException - if accessing AAS property values or performing operation invocations fails
    • testAasResult

      public static void testAasResult(AasCreator.AasResult result, de.iip_ecosphere.platform.services.environment.Service expected)
      Does further tests based on the given result instance.
      Parameters:
      result - the AAS result instance to test
      expected - expected service (with values)
    • assertProperty

      private static void assertProperty(de.iip_ecosphere.platform.support.aas.Submodel submodel, String propertyName, Function<Object,Boolean> cond) throws ExecutionException
      Asserts a property/value.
      Parameters:
      submodel - the submodel
      propertyName - the name/short id of the property
      cond - a condition to apply on the property value, if null the property value must be null
      Throws:
      ExecutionException - if accessing AAS property values or performing operation invocations fails
    • assertOperation

      private static void assertOperation(de.iip_ecosphere.platform.support.aas.Submodel submodel, String operationName, Function<String,Boolean> cond, Function<Exception,Boolean> exc, Object... args) throws ExecutionException
      Asserts an operation invocation result through JsonResultWrapper.fromJson(Object).
      Parameters:
      submodel - the submodel
      operationName - the name/short id of the operation
      cond - a condition to apply on the result value, if null no assert is performed
      exc - a condition to apply on the result value, if null no assert is performed but also no exception may occur
      args - the operation invocation arguments
      Throws:
      ExecutionException - if accessing AAS property values or performing operation invocations fails and exc does not allow for catching/asserting
    • checkNonEmptyString

      private static boolean checkNonEmptyString(Object obj)
      Checks whether obj is a non-empty string.
      Parameters:
      obj - the object to test
      Returns:
      true if o fulfills the properties to test, false else
    • checkEmptyString

      private static boolean checkEmptyString(Object obj)
      Checks whether obj is an empty string.
      Parameters:
      obj - the object to test
      Returns:
      true if o fulfills the properties to test, false else
    • checkString

      private static boolean checkString(Object obj, String expected)
      Checks whether obj is a non-empty string.
      Parameters:
      obj - the object to test
      expected - the expected value, may be null then we check for obj null
      Returns:
      true if o fulfills the properties to test, false else
    • checkVersion

      private static boolean checkVersion(Object obj, de.iip_ecosphere.platform.support.Version expected)
      Checks whether the given obj complies with the expected version.
      Parameters:
      obj - the object to test
      expected - the expected version, may be null then we check for obj null
      Returns:
      true if o fulfills the properties to test, false else
    • checkBoolean

      private static boolean checkBoolean(Object obj)
      Checks whether obj is a boolean.
      Parameters:
      obj - the object to test
      Returns:
      true if o fulfills the properties to test, false else
    • checkBoolean

      private static boolean checkBoolean(Object obj, boolean expectedValue)
      Checks whether obj is a boolean with expectedValue.
      Parameters:
      obj - the object to test
      expectedValue - the expected value
      Returns:
      true if obj fulfills the properties to test, false else
    • checkStateString

      private static boolean checkStateString(Object obj)
      Checks whether obj is a string representing a value of ServiceState.
      Parameters:
      obj - the object to test
      Returns:
      true if o fulfills the properties to test, false else
    • checkStateString

      private static boolean checkStateString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceState expectedValue)
      Checks whether obj is a string representing a value of ServiceState.
      Parameters:
      obj - the object to test
      expectedValue - the expected state value, no test is performed if null
      Returns:
      true if o fulfills the properties to test, false else
    • checkKindString

      private static boolean checkKindString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceKind expectedValue)
      Checks whether obj is a string representing a value of ServiceKind.
      Parameters:
      obj - the object to test
      expectedValue - the expected state value, no test is performed if null
      Returns:
      true if o fulfills the properties to test, false else