Class AbstractEnvironmentTest
java.lang.Object
test.de.iip_ecosphere.platform.services.environment.AbstractEnvironmentTest
- Direct Known Subclasses:
JavaEnvironmentTest,PythonEnvironmentSuiteTest,PythonEnvironmentTest
The common test code for all environments. Maximize code here rather than in specific environment tests.
- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidassertOperation(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 throughJsonResultWrapper.fromJson(Object).private static voidassertProperty(de.iip_ecosphere.platform.support.aas.Submodel submodel, String propertyName, Function<Object, Boolean> cond) Asserts a property/value.private static booleancheckBoolean(Object obj) Checks whetherobjis a boolean.private static booleancheckBoolean(Object obj, boolean expectedValue) Checks whetherobjis a boolean withexpectedValue.private static booleancheckEmptyString(Object obj) Checks whetherobjis an empty string.private static booleancheckKindString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceKind expectedValue) Checks whetherobjis a string representing a value ofServiceKind.private static booleanChecks whetherobjis a non-empty string.private static booleancheckStateString(Object obj) Checks whetherobjis a string representing a value ofServiceState.private static booleancheckStateString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceState expectedValue) Checks whetherobjis a string representing a value ofServiceState.private static booleancheckString(Object obj, String expected) Checks whetherobjis a non-empty string.private static booleancheckVersion(Object obj, de.iip_ecosphere.platform.support.Version expected) Checks whether the givenobjcomplies with theexpectedversion.static voidtestAas(de.iip_ecosphere.platform.support.aas.SetupSpec spec, de.iip_ecosphere.platform.services.environment.Service expected) Tests the agreed AAS behavior created byAasCreator.static voidtestAasResult(AasCreator.AasResult result, de.iip_ecosphere.platform.services.environment.Service expected) Does further tests based on the given result instance.
-
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 byAasCreator.- Parameters:
spec- the setup specificationexpected- expected service (with values)- Throws:
IOException- if accessing the AAS failsExecutionException- 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 testexpected- expected service (with values)
-
assertProperty
private static void assertProperty(de.iip_ecosphere.platform.support.aas.Submodel submodel, String propertyName, Function<Object, Boolean> cond) throws ExecutionExceptionAsserts a property/value.- Parameters:
submodel- the submodelpropertyName- the name/short id of the propertycond- 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, throws ExecutionExceptionBoolean> exc, Object... args) Asserts an operation invocation result throughJsonResultWrapper.fromJson(Object).- Parameters:
submodel- the submodeloperationName- the name/short id of the operationcond- a condition to apply on the result value, if null no assert is performedexc- a condition to apply on the result value, if null no assert is performed but also no exception may occurargs- the operation invocation arguments- Throws:
ExecutionException- if accessing AAS property values or performing operation invocations fails andexcdoes not allow for catching/asserting
-
checkNonEmptyString
Checks whetherobjis a non-empty string.- Parameters:
obj- the object to test- Returns:
trueifofulfills the properties to test,falseelse
-
checkEmptyString
Checks whetherobjis an empty string.- Parameters:
obj- the object to test- Returns:
trueifofulfills the properties to test,falseelse
-
checkString
Checks whetherobjis a non-empty string.- Parameters:
obj- the object to testexpected- the expected value, may be null then we check forobjnull- Returns:
trueifofulfills the properties to test,falseelse
-
checkVersion
Checks whether the givenobjcomplies with theexpectedversion.- Parameters:
obj- the object to testexpected- the expected version, may be null then we check forobjnull- Returns:
trueifofulfills the properties to test,falseelse
-
checkBoolean
Checks whetherobjis a boolean.- Parameters:
obj- the object to test- Returns:
trueifofulfills the properties to test,falseelse
-
checkBoolean
Checks whetherobjis a boolean withexpectedValue.- Parameters:
obj- the object to testexpectedValue- the expected value- Returns:
trueifobjfulfills the properties to test,falseelse
-
checkStateString
Checks whetherobjis a string representing a value ofServiceState.- Parameters:
obj- the object to test- Returns:
trueifofulfills the properties to test,falseelse
-
checkStateString
private static boolean checkStateString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceState expectedValue) Checks whetherobjis a string representing a value ofServiceState.- Parameters:
obj- the object to testexpectedValue- the expected state value, no test is performed if null- Returns:
trueifofulfills the properties to test,falseelse
-
checkKindString
private static boolean checkKindString(Object obj, de.iip_ecosphere.platform.services.environment.ServiceKind expectedValue) Checks whetherobjis a string representing a value ofServiceKind.- Parameters:
obj- the object to testexpectedValue- the expected state value, no test is performed if null- Returns:
trueifofulfills the properties to test,falseelse
-