Class MockInterceptor

java.lang.Object
de.iip_ecosphere.platform.deviceMgt.MockInterceptor
All Implemented Interfaces:
de.iip_ecosphere.platform.support.aas.OperationsProvider.Interceptor

public class MockInterceptor extends Object implements de.iip_ecosphere.platform.support.aas.OperationsProvider.Interceptor
Test mocking interceptor, as mocking some objects does not work anymore through plugins, classloading. Might be some side effects are now prevented.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • MockInterceptor

      public MockInterceptor()
  • Method Details

    • getKey

      private String getKey(String category, String name)
      Returns an operation key.
      Parameters:
      category - the category
      name - the operation name
      Returns:
      the key
    • getOperation

      public Function<Object[],Object> getOperation(String category, String name, Function<Object[],Object> origin)
      Specified by:
      getOperation in interface de.iip_ecosphere.platform.support.aas.OperationsProvider.Interceptor
    • intercept

      public void intercept(String name, Function<Object[],Object> function)
      Intercept an operation with default category.
      Parameters:
      name - the name of the operation
      function - the replacement function to be used when the original is being called
      See Also:
    • intercept

      public void intercept(String category, String name, Function<Object[],Object> function)
      Intercept an operation with a given category.
      Parameters:
      category - the category
      name - the name of the operation
      function - the replacement function to be used when the original is being called
    • getCalls

      public int getCalls(String name)
      Returns the number of calls to a given operation with default category.
      Parameters:
      name - the name of the operation
      Returns:
      the number of calls
    • getCounter

      private int getCounter(String key)
      Returns the call counter for the given key.
      Parameters:
      key - the key (getKey(String, String)
      Returns:
      the number of calls
    • getCalls

      public int getCalls(String category, String name)
      Returns the number of calls to a given operation with default category.
      Parameters:
      category - the category
      name - the name of the operation
      Returns:
      the number of calls
    • clear

      public void clear()
      Clears the intercepted operations and the number of calls. Resets the interceptor to no interception and no calls done.