PostgresMetadataDAO extends PostgresBaseDAO implements MetadataDAO, EventHandlerDAO { @Override public void createWorkflowDef(WorkflowDef def) { validate(def); withTransaction(tx -> { if (workflowExists(tx, def)) { throw new ApplicationException(ApplicationException.Code.CONFLICT, "Workflow with " + def.key() + " already exists!"); } insertOrUpdateWorkflowDef(tx, def); }); } @Inject  PostgresMetadataDAO(ObjectMapper om, DataSource dataSource, 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 Optional<WorkflowDef> getLatestWorkflowDef(String name); @Override Optional<WorkflowDef> getWorkflowDef(String name, int version); @Override void removeWorkflowDef(String name, Integer version); List<String> findAll(); @Override List<WorkflowDef> getAllWorkflowDefs(); List<WorkflowDef> getAllLatest(); List<WorkflowDef> getAllVersions(String name); @Override void addEventHandler(EventHandler eventHandler); @Override void updateEventHandler(EventHandler eventHandler); @Override void removeEventHandler(String name); @Override List<EventHandler> getAllEventHandlers(); @Override List<EventHandler> getEventHandlersForEvent(String event, boolean activeOnly); static final String PROP_TASKDEF_CACHE_REFRESH; static final int DEFAULT_TASKDEF_CACHE_REFRESH_SECONDS; }
@Test(expected=ApplicationException.class) public void testDuplicate() throws Exception { WorkflowDef def = new WorkflowDef(); def.setName("testDuplicate"); def.setVersion(1); dao.createWorkflowDef(def); dao.createWorkflowDef(def); }