@Test public void shouldInsertRegimenColumn() throws Exception { Long userId = 5L; List<RegimenColumn> regimenColumns = new ArrayList<>(); RegimenColumn regimenColumn = new RegimenColumn(); regimenColumns.add(regimenColumn); RegimenTemplate regimenTemplate = new RegimenTemplate(1l, regimenColumns); repository.save(regimenTemplate, userId); verify(mapper).insert(regimenColumn, regimenTemplate.getProgramId()); assertThat(regimenColumn.getModifiedBy(), is(userId)); assertThat(regimenColumn.getCreatedBy(), is(userId)); }
public void save(RegimenTemplate regimenTemplate, Long userId) { for (Column regimenColumn : regimenTemplate.getColumns()) { regimenColumn.setModifiedBy(userId); if (regimenColumn.getId() == null) { regimenColumn.setCreatedBy(userId); mapper.insert((RegimenColumn) regimenColumn, regimenTemplate.getProgramId()); } mapper.update((RegimenColumn) regimenColumn); } }
RegimenColumnRepository { public void save(RegimenTemplate regimenTemplate, Long userId) { for (Column regimenColumn : regimenTemplate.getColumns()) { regimenColumn.setModifiedBy(userId); if (regimenColumn.getId() == null) { regimenColumn.setCreatedBy(userId); mapper.insert((RegimenColumn) regimenColumn, regimenTemplate.getProgramId()); } mapper.update((RegimenColumn) regimenColumn); } } }
RegimenColumnRepository { public void save(RegimenTemplate regimenTemplate, Long userId) { for (Column regimenColumn : regimenTemplate.getColumns()) { regimenColumn.setModifiedBy(userId); if (regimenColumn.getId() == null) { regimenColumn.setCreatedBy(userId); mapper.insert((RegimenColumn) regimenColumn, regimenTemplate.getProgramId()); } mapper.update((RegimenColumn) regimenColumn); } }  }
RegimenColumnRepository { public void save(RegimenTemplate regimenTemplate, Long userId) { for (Column regimenColumn : regimenTemplate.getColumns()) { regimenColumn.setModifiedBy(userId); if (regimenColumn.getId() == null) { regimenColumn.setCreatedBy(userId); mapper.insert((RegimenColumn) regimenColumn, regimenTemplate.getProgramId()); } mapper.update((RegimenColumn) regimenColumn); } }  List<RegimenColumn> getRegimenColumnsByProgramId(Long programId); List<RegimenColumn> getMasterRegimenColumnsByProgramId(); void save(RegimenTemplate regimenTemplate, Long userId); }
RegimenColumnRepository { public void save(RegimenTemplate regimenTemplate, Long userId) { for (Column regimenColumn : regimenTemplate.getColumns()) { regimenColumn.setModifiedBy(userId); if (regimenColumn.getId() == null) { regimenColumn.setCreatedBy(userId); mapper.insert((RegimenColumn) regimenColumn, regimenTemplate.getProgramId()); } mapper.update((RegimenColumn) regimenColumn); } }  List<RegimenColumn> getRegimenColumnsByProgramId(Long programId); List<RegimenColumn> getMasterRegimenColumnsByProgramId(); void save(RegimenTemplate regimenTemplate, Long userId);  }