src/test/java/com/github/mongobee/LockCheckerIntegrationTest.java
private void injectDependencies() throws NoSuchFieldException, IllegalAccessException {

    Field changeServiceField = null;
    Field proxyFactoryField = null;
    Field lockRepositoryField = null;
    Field lockCheckerField = null;

    try {
      changeServiceField = runner.getClass().getDeclaredField("service");
      changeServiceField.setAccessible(true);
      changeServiceField.set(runner, changeService);

      proxyFactoryField = runner.getClass().getDeclaredField("proxyFactory");
      proxyFactoryField.setAccessible(true);
      proxyFactoryField.set(runner, proxyFactory);

      lockRepositoryField = runner.getClass().getDeclaredField("lockRepository");
      lockRepositoryField.setAccessible(true);
      lockRepositoryField.set(runner, lockRepository);

      lockCheckerField = runner.getClass().getDeclaredField("lockChecker");
      lockCheckerField.setAccessible(true);
      lockCheckerField.set(runner, lockChecker);

    } finally {
      if (changeServiceField != null) changeServiceField.setAccessible(false);
      if (proxyFactoryField != null) proxyFactoryField.setAccessible(false);
      if (lockRepositoryField != null) lockRepositoryField.setAccessible(false);
      if (lockCheckerField != null) lockCheckerField.setAccessible(false);
    }

  }
//Private helper method to inject dependencies with reflection to avoid modifying production code for testing purpose
Private helper method to inject dependencies with reflection to avoid modifying production code for testing purpose
Private helper method to inject dependencies with reflection to avoid modifying production code for testing purpose
private void injectDependencies() throws NoSuchFieldException, IllegalAccessException {
    Field changeServiceField = null;
    Field proxyFactoryField = null;
    Field lockRepositoryField = null;
    Field lockCheckerField = null;
    try {
      changeServiceField = runner.getClass().getDeclaredField("service");
      changeServiceField.setAccessible(true);
      changeServiceField.set(runner, changeService);
      proxyFactoryField = runner.getClass().getDeclaredField("proxyFactory");
      proxyFactoryField.setAccessible(true);
      proxyFactoryField.set(runner, proxyFactory);
      lockRepositoryField = runner.getClass().getDeclaredField("lockRepository");
      lockRepositoryField.setAccessible(true);
      lockRepositoryField.set(runner, lockRepository);
      lockCheckerField = runner.getClass().getDeclaredField("lockChecker");
      lockCheckerField.setAccessible(true);
      lockCheckerField.set(runner, lockChecker);
    } finally {
      if (changeServiceField != null) changeServiceField.setAccessible(false);
      if (proxyFactoryField != null) proxyFactoryField.setAccessible(false);
      if (lockRepositoryField != null) lockRepositoryField.setAccessible(false);
      if (lockCheckerField != null) lockCheckerField.setAccessible(false);
    }
  }
private void injectDependencies ( ) throws NoSuchFieldException , IllegalAccessException { Field changeServiceField = null ; Field proxyFactoryField = null ; Field lockRepositoryField = null ; Field lockCheckerField = null ; try { changeServiceField = runner . getClass ( ) . getDeclaredField ( "service" ) ; changeServiceField . setAccessible ( true ) ; changeServiceField . set ( runner , changeService ) ; proxyFactoryField = runner . getClass ( ) . getDeclaredField ( "proxyFactory" ) ; proxyFactoryField . setAccessible ( true ) ; proxyFactoryField . set ( runner , proxyFactory ) ; lockRepositoryField = runner . getClass ( ) . getDeclaredField ( "lockRepository" ) ; lockRepositoryField . setAccessible ( true ) ; lockRepositoryField . set ( runner , lockRepository ) ; lockCheckerField = runner . getClass ( ) . getDeclaredField ( "lockChecker" ) ; lockCheckerField . setAccessible ( true ) ; lockCheckerField . set ( runner , lockChecker ) ; } finally { if ( changeServiceField != null ) changeServiceField . setAccessible ( false ) ; if ( proxyFactoryField != null ) proxyFactoryField . setAccessible ( false ) ; if ( lockRepositoryField != null ) lockRepositoryField . setAccessible ( false ) ; if ( lockCheckerField != null ) lockCheckerField . setAccessible ( false ) ; } }
Private helper method to inject dependencies with reflection to avoid modifying production code for testing purpose
Private helper method to inject dependencies with reflection to avoid modifying production code for testing purpose