SpecOfferBenefitParametersExtractor extends AbstractParametersExtractor<SpecOfferBenefit> { @Override public Map<String, Object> getParameters(final SpecOfferBenefit entity, final Map<String, Object> parameters) { addParameter(entity.getSpecOffer(), specOfferDao, "specOffer", parameters); addParameter(entity.getBenefit(), benefitDao, "benefit", parameters); return parameters; }  @Override Map<String, Object> getParameters(final SpecOfferBenefit entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { Long specOfferId = 1L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long benefitId = 2L; Benefit benefit = new Benefit(); benefit.setId(benefitId); SpecOfferBenefit entity = new SpecOfferBenefit(); entity.setSpecOffer(specOffer); entity.setBenefit(benefit); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("specOffer", specOffer); expected.put("benefit", benefit); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(benefitDao.getEntityById(anyLong())).thenReturn(benefit); Map<String, Object> actual = unit.getParameters(entity); verify(specOfferDao).getEntityById(specOfferId); verify(benefitDao).getEntityById(benefitId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long specOfferId = 1L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long benefitId = 2L; Benefit benefit = new Benefit(); benefit.setId(benefitId); SpecOfferBenefit entity = new SpecOfferBenefit(); entity.setSpecOffer(specOffer); entity.setBenefit(benefit); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("specOffer", specOffer); expected.put("benefit", benefit); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(benefitDao.getEntityById(anyLong())).thenReturn(benefit); Map<String, Object> actual = unit.getParameters(entity); verify(specOfferDao).getEntityById(specOfferId); verify(benefitDao).getEntityById(benefitId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { SpecOfferBenefit entity = new SpecOfferBenefit(); 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 testGetParametersWithDefaultEntityAndDisabledDEfaults() throws Exception { unit.setActive(false); unit.setSecurity(false); SpecOfferBenefit entity = new SpecOfferBenefit(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledStatus() throws Exception { unit.setActive(false); SpecOfferBenefit entity = new SpecOfferBenefit(); 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 testGetParametersWithDefaultEntityAndDisabledSecurity() throws Exception { unit.setSecurity(false); SpecOfferBenefit entity = new SpecOfferBenefit(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }