PersonPaperParametersExtractor extends AbstractParametersExtractor<PersonPaper> { @Override public Map<String, Object> getParameters(final PersonPaper entity, final Map<String, Object> parameters) { addParameter(entity.getPerson(), personDao, "person", parameters); addParameter(entity.getPaperType(), paperTypeDao, "paperType", parameters); addParameter(entity.getHonorsType(), honorTypeDao, "honorsType", parameters); addParameter(entity.getDocSeries(), "docSeries", parameters); addParameter(entity.getDocNum(), "docNum", parameters); addParameter(entity.getDocDate(), "docDate", parameters); addParameter(entity.getDocIssued(), "docIssued", parameters); addParameter(entity.getDocPin(), "docPin", parameters); addParameter(entity.getMark(), "mark", parameters); addParameter(entity.getIsChecked(), "isChecked", parameters); addParameter(entity.getIsForeign(), "isForeign", parameters); return parameters; }  @Override Map<String, Object> getParameters(final PersonPaper entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { String docSeries = "doc series"; String docNum = "doc nu"; Date docDate = new Date(); String docIssued = "doc issued"; String docPin = "doc pin"; Double mark = 2.5; Integer isChecked = 1; Integer isForeign = 2; Long personId = 1L; Person person = new Person(); person.setId(personId); Long paperTypeId = 2L; PaperType paperType = new PaperType(); paperType.setId(paperTypeId); Long honorTypeId = 4L; HonorType honorsType = new HonorType(); honorsType.setId(honorTypeId); PersonPaper entity = new PersonPaper(); entity.setPerson(person); entity.setPaperType(paperType); entity.setHonorsType(honorsType); entity.setDocSeries(docSeries); entity.setDocNum(docNum); entity.setDocDate(docDate); entity.setDocIssued(docIssued); entity.setDocPin(docPin); entity.setMark(mark); entity.setIsChecked(isChecked); entity.setIsForeign(isForeign); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("paperType", paperType); expected.put("honorsType", honorsType); expected.put("docSeries", docSeries); expected.put("docNum", docNum); expected.put("docDate", docDate); expected.put("docIssued", docIssued); expected.put("docPin", docPin); expected.put("mark", mark); expected.put("isChecked", isChecked); expected.put("isForeign", isForeign); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(personDao.getEntityById(anyLong())).thenReturn(person); when(paperTypeDao.getEntityById(anyLong())).thenReturn(paperType); when(honorTypeDao.getEntityById(anyLong())).thenReturn(honorsType); Map<String, Object> actual = unit.getParameters(entity); verify(personDao).getEntityById(personId); verify(paperTypeDao).getEntityById(paperTypeId); verify(honorTypeDao).getEntityById(honorTypeId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); String docSeries = "doc series"; String docNum = "doc nu"; Date docDate = new Date(); String docIssued = "doc issued"; String docPin = "doc pin"; Double mark = 2.5; Integer isChecked = 1; Integer isForeign = 2; Long personId = 1L; Person person = new Person(); person.setId(personId); Long paperTypeId = 2L; PaperType paperType = new PaperType(); paperType.setId(paperTypeId); Long honorTypeId = 4L; HonorType honorsType = new HonorType(); honorsType.setId(honorTypeId); PersonPaper entity = new PersonPaper(); entity.setPerson(person); entity.setPaperType(paperType); entity.setHonorsType(honorsType); entity.setDocSeries(docSeries); entity.setDocNum(docNum); entity.setDocDate(docDate); entity.setDocIssued(docIssued); entity.setDocPin(docPin); entity.setMark(mark); entity.setIsChecked(isChecked); entity.setIsForeign(isForeign); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("paperType", paperType); expected.put("honorsType", honorsType); expected.put("docSeries", docSeries); expected.put("docNum", docNum); expected.put("docDate", docDate); expected.put("docIssued", docIssued); expected.put("docPin", docPin); expected.put("mark", mark); expected.put("isChecked", isChecked); expected.put("isForeign", isForeign); when(personDao.getEntityById(anyLong())).thenReturn(person); when(paperTypeDao.getEntityById(anyLong())).thenReturn(paperType); when(honorTypeDao.getEntityById(anyLong())).thenReturn(honorsType); Map<String, Object> actual = unit.getParameters(entity); verify(personDao).getEntityById(personId); verify(paperTypeDao).getEntityById(paperTypeId); verify(honorTypeDao).getEntityById(honorTypeId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { PersonPaper entity = new PersonPaper(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledSecurity() throws Exception { unit.setSecurity(false); PersonPaper entity = new PersonPaper(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledStatus() throws Exception { unit.setActive(false); PersonPaper entity = new PersonPaper(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); PersonPaper entity = new PersonPaper(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }