@Test public void testHandle() throws ResourceAllocationException { final BaseAsyncCreateCmd asyncCreateCmd = mock(BaseAsyncCreateCmd.class); final Map<String, String> params = new HashMap<>(); final Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); final UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN); CallContext.register(user, account); final CommandCreationWorker creationWorker = new CommandCreationWorker(); creationWorker.handle(new DispatchTask(asyncCreateCmd, params)); verify(asyncCreateCmd, times(1)).create(); }
@Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd) cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } }
CommandCreationWorker implements DispatchWorker { @Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd) cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } } }
CommandCreationWorker implements DispatchWorker { @Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd) cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } }  }
CommandCreationWorker implements DispatchWorker { @Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd) cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } }  @Override void handle(final DispatchTask task); }
CommandCreationWorker implements DispatchWorker { @Override public void handle(final DispatchTask task) { final BaseCmd cmd = task.getCmd(); if (cmd instanceof BaseAsyncCreateCmd) { try { CallContext.current().setEventDisplayEnabled(cmd.isDisplay()); ((BaseAsyncCreateCmd) cmd).create(); } catch (final ResourceAllocationException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, e.getMessage(), e); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ATTEMP_TO_CREATE_NON_CREATION_CMD); } }  @Override void handle(final DispatchTask task);  }