@Test public void convertWorks() { WorkflowInstance i = new WorkflowInstance.Builder().setId(1).setType("dummy").setBusinessKey("businessKey") .setExternalId("externalId").build(); CreateWorkflowInstanceResponse resp = converter.convert(i); assertThat(resp.id, equalTo(i.id)); assertThat(resp.type, equalTo(i.type)); assertThat(resp.businessKey, equalTo(i.businessKey)); assertThat(resp.externalId, equalTo(i.externalId)); }
public WorkflowInstance convert(CreateWorkflowInstanceRequest req) { WorkflowInstance.Builder builder = factory.newWorkflowInstanceBuilder().setType(req.type).setBusinessKey(req.businessKey) .setExternalId(req.externalId); if (!FALSE.equals(req.activate)) { if (req.activationTime != null) { builder.setNextActivation(req.activationTime); } } else { builder.setNextActivation(null); } builder.setParentWorkflowId(req.parentWorkflowId); if (isNotEmpty(req.startState)) { builder.setState(req.startState); } for (Entry<String, Object> entry : req.stateVariables.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { builder.putStateVariable(entry.getKey(), (String) value); } else { builder.putStateVariable(entry.getKey(), value); } } return builder.build(); }
CreateWorkflowConverter { public WorkflowInstance convert(CreateWorkflowInstanceRequest req) { WorkflowInstance.Builder builder = factory.newWorkflowInstanceBuilder().setType(req.type).setBusinessKey(req.businessKey) .setExternalId(req.externalId); if (!FALSE.equals(req.activate)) { if (req.activationTime != null) { builder.setNextActivation(req.activationTime); } } else { builder.setNextActivation(null); } builder.setParentWorkflowId(req.parentWorkflowId); if (isNotEmpty(req.startState)) { builder.setState(req.startState); } for (Entry<String, Object> entry : req.stateVariables.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { builder.putStateVariable(entry.getKey(), (String) value); } else { builder.putStateVariable(entry.getKey(), value); } } return builder.build(); } }
CreateWorkflowConverter { public WorkflowInstance convert(CreateWorkflowInstanceRequest req) { WorkflowInstance.Builder builder = factory.newWorkflowInstanceBuilder().setType(req.type).setBusinessKey(req.businessKey) .setExternalId(req.externalId); if (!FALSE.equals(req.activate)) { if (req.activationTime != null) { builder.setNextActivation(req.activationTime); } } else { builder.setNextActivation(null); } builder.setParentWorkflowId(req.parentWorkflowId); if (isNotEmpty(req.startState)) { builder.setState(req.startState); } for (Entry<String, Object> entry : req.stateVariables.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { builder.putStateVariable(entry.getKey(), (String) value); } else { builder.putStateVariable(entry.getKey(), value); } } return builder.build(); } @Inject  CreateWorkflowConverter(WorkflowInstanceFactory factory); }
CreateWorkflowConverter { public WorkflowInstance convert(CreateWorkflowInstanceRequest req) { WorkflowInstance.Builder builder = factory.newWorkflowInstanceBuilder().setType(req.type).setBusinessKey(req.businessKey) .setExternalId(req.externalId); if (!FALSE.equals(req.activate)) { if (req.activationTime != null) { builder.setNextActivation(req.activationTime); } } else { builder.setNextActivation(null); } builder.setParentWorkflowId(req.parentWorkflowId); if (isNotEmpty(req.startState)) { builder.setState(req.startState); } for (Entry<String, Object> entry : req.stateVariables.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { builder.putStateVariable(entry.getKey(), (String) value); } else { builder.putStateVariable(entry.getKey(), value); } } return builder.build(); } @Inject  CreateWorkflowConverter(WorkflowInstanceFactory factory); WorkflowInstance convert(CreateWorkflowInstanceRequest req); CreateWorkflowInstanceResponse convert(WorkflowInstance instance); }
CreateWorkflowConverter { public WorkflowInstance convert(CreateWorkflowInstanceRequest req) { WorkflowInstance.Builder builder = factory.newWorkflowInstanceBuilder().setType(req.type).setBusinessKey(req.businessKey) .setExternalId(req.externalId); if (!FALSE.equals(req.activate)) { if (req.activationTime != null) { builder.setNextActivation(req.activationTime); } } else { builder.setNextActivation(null); } builder.setParentWorkflowId(req.parentWorkflowId); if (isNotEmpty(req.startState)) { builder.setState(req.startState); } for (Entry<String, Object> entry : req.stateVariables.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { builder.putStateVariable(entry.getKey(), (String) value); } else { builder.putStateVariable(entry.getKey(), value); } } return builder.build(); } @Inject  CreateWorkflowConverter(WorkflowInstanceFactory factory); WorkflowInstance convert(CreateWorkflowInstanceRequest req); CreateWorkflowInstanceResponse convert(WorkflowInstance instance);  }