### Question:
AccountPermissioningController { public boolean isPermitted(final Transaction transaction, final boolean includeOnChainCheck) { final Hash transactionHash = transaction.getHash(); final Address sender = transaction.getSender(); LOG.trace("Account permissioning: Checking transaction {}", transactionHash); boolean permitted; if (includeOnChainCheck) { permitted = accountLocalConfigPermissioningController .map(c -> c.isPermitted(transaction)) .orElse(true) && transactionSmartContractPermissioningController .map(c -> c.isPermitted(transaction)) .orElse(true); } else { permitted = accountLocalConfigPermissioningController .map(c -> c.isPermitted(transaction)) .orElse(true); } if (permitted) { LOG.trace("Account permissioning: Permitted transaction {} from {}", transactionHash, sender); } else { LOG.trace("Account permissioning: Rejected transaction {} from {}", transactionHash, sender); } return permitted; } AccountPermissioningController(
      final Optional<AccountLocalConfigPermissioningController>
          accountLocalConfigPermissioningController,
      final Optional<TransactionSmartContractPermissioningController>
          transactionSmartContractPermissioningController); boolean isPermitted(final Transaction transaction, final boolean includeOnChainCheck); Optional<AccountLocalConfigPermissioningController> getAccountLocalConfigPermissioningController();  }### Answer:
@Test public void shouldOnlyCheckLocalConfigControllerWhenNotPersistingState() { when(localConfigController.isPermitted(any())).thenReturn(true); boolean isPermitted = permissioningController.isPermitted(mock(Transaction.class), false); assertThat(isPermitted).isTrue(); verify(localConfigController).isPermitted(any()); verifyZeroInteractions(smartContractController); }
@Test public void shouldOnlyCheckLocalConfigAndSmartContractControllerWhenPersistingState() { when(localConfigController.isPermitted(any())).thenReturn(true); when(smartContractController.isPermitted(any())).thenReturn(true); boolean isPermitted = permissioningController.isPermitted(mock(Transaction.class), true); assertThat(isPermitted).isTrue(); verify(localConfigController).isPermitted(any()); verify(smartContractController).isPermitted(any()); }
@Test public void shouldReturnFalseIfOneControllerPermitsAndTheOtherDoesNot() { when(localConfigController.isPermitted(any())).thenReturn(true); when(smartContractController.isPermitted(any())).thenReturn(false); boolean isPermitted = permissioningController.isPermitted(mock(Transaction.class), true); assertThat(isPermitted).isFalse(); verify(localConfigController).isPermitted(any()); verify(smartContractController).isPermitted(any()); }