@Test(expected = DataAccessException.class) public void willNotCreateDuplicateGroup() throws Exception { groupDAO.createGroup("group1", "creator1", "", ImmutableMap.of()); }
public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) { GroupsRecord r = dslContext.newRecord(GROUPS); String jsonMetadata; try { jsonMetadata = mapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } long now = OffsetDateTime.now().toEpochSecond(); r.setName(name); r.setCreatedby(creator); r.setCreatedat(now); r.setUpdatedby(creator); r.setUpdatedat(now); r.setDescription(description); r.setMetadata(jsonMetadata); r.store(); return r.getId(); }
GroupDAO { public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) { GroupsRecord r = dslContext.newRecord(GROUPS); String jsonMetadata; try { jsonMetadata = mapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } long now = OffsetDateTime.now().toEpochSecond(); r.setName(name); r.setCreatedby(creator); r.setCreatedat(now); r.setUpdatedby(creator); r.setUpdatedat(now); r.setDescription(description); r.setMetadata(jsonMetadata); r.store(); return r.getId(); } }
GroupDAO { public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) { GroupsRecord r = dslContext.newRecord(GROUPS); String jsonMetadata; try { jsonMetadata = mapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } long now = OffsetDateTime.now().toEpochSecond(); r.setName(name); r.setCreatedby(creator); r.setCreatedat(now); r.setUpdatedby(creator); r.setUpdatedat(now); r.setDescription(description); r.setMetadata(jsonMetadata); r.store(); return r.getId(); } private  GroupDAO(DSLContext dslContext, GroupMapper groupMapper, ObjectMapper mapper); }
GroupDAO { public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) { GroupsRecord r = dslContext.newRecord(GROUPS); String jsonMetadata; try { jsonMetadata = mapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } long now = OffsetDateTime.now().toEpochSecond(); r.setName(name); r.setCreatedby(creator); r.setCreatedat(now); r.setUpdatedby(creator); r.setUpdatedat(now); r.setDescription(description); r.setMetadata(jsonMetadata); r.store(); return r.getId(); } private  GroupDAO(DSLContext dslContext, GroupMapper groupMapper, ObjectMapper mapper); long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata); void deleteGroup(Group group); Optional<Group> getGroup(String name); Optional<Group> getGroupById(long id); ImmutableSet<Group> getGroups(); }
GroupDAO { public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) { GroupsRecord r = dslContext.newRecord(GROUPS); String jsonMetadata; try { jsonMetadata = mapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } long now = OffsetDateTime.now().toEpochSecond(); r.setName(name); r.setCreatedby(creator); r.setCreatedat(now); r.setUpdatedby(creator); r.setUpdatedat(now); r.setDescription(description); r.setMetadata(jsonMetadata); r.store(); return r.getId(); } private  GroupDAO(DSLContext dslContext, GroupMapper groupMapper, ObjectMapper mapper); long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata); void deleteGroup(Group group); Optional<Group> getGroup(String name); Optional<Group> getGroupById(long id); ImmutableSet<Group> getGroups();  }