RedisMetadataDAO extends BaseDynoDAO implements MetadataDAO { @Override public void createWorkflowDef(WorkflowDef def) { if (dynoClient.hexists(nsKey(WORKFLOW_DEF, def.getName()), String.valueOf(def.getVersion()))) { throw new ApplicationException(Code.CONFLICT, "Workflow with " + def.key() + " already exists!"); } _createOrUpdate(def); } @Inject  RedisMetadataDAO(DynoProxy dynoClient, ObjectMapper objectMapper, Configuration config); @Override void createTaskDef(TaskDef taskDef); @Override String updateTaskDef(TaskDef taskDef); @Override TaskDef getTaskDef(String name); @Override List<TaskDef> getAllTaskDefs(); @Override void removeTaskDef(String name); @Override void createWorkflowDef(WorkflowDef def); @Override void updateWorkflowDef(WorkflowDef def); @Override /* * @param name Name of the workflow definition * @return Latest version of workflow definition * @see WorkflowDef */ Optional<WorkflowDef> getLatestWorkflowDef(String name); List<WorkflowDef> getAllVersions(String name); @Override Optional<WorkflowDef> getWorkflowDef(String name, int version); @Override void removeWorkflowDef(String name, Integer version); List<String> findAll(); @Override List<WorkflowDef> getAllWorkflowDefs();  }
@Test(expected = ApplicationException.class) public void testDup() { WorkflowDef def = new WorkflowDef(); def.setName("testDup"); def.setVersion(1); redisMetadataDAO.createWorkflowDef(def); redisMetadataDAO.createWorkflowDef(def); }