public static void assertCashPoint(CashPoint expected, CashPoint actual) { assertOpenmrsMetadata(expected, actual); Assert.assertEquals(expected.getName(), actual.getName()); Assert.assertEquals(expected.getDescription(), actual.getDescription()); if (expected.getLocation() == null) { Assert.assertNull(actual.getLocation()); } else { Assert.assertEquals(expected.getLocation().getId(), actual.getLocation().getId()); } }
/** * @verifies not return retired cashpoints unless specified * @see ICashPointService#getCashPointsByLocationAndName(org.openmrs.Location, String, boolean) */ @Test public void getCashPointsByLocationAndName_shouldNotReturnRetiredCashpointsUnlessSpecified() throws Exception { CashPoint cashPoint = service.getById(0); cashPoint.setRetired(true); cashPoint.setRetireReason("reason"); service.save(cashPoint); Location location = Context.getLocationService().getLocation(0); Context.flushSession(); List<CashPoint> results = service.getCashPointsByLocationAndName(location, "Test", false); Assert.assertNotNull(results); Assert.assertEquals(2, results.size()); Assert.assertEquals(4, (int) Iterators.get(results.iterator(), 0).getId()); Assert.assertEquals(5, (int) Iterators.get(results.iterator(), 1).getId()); List<CashPoint> results1 = service.getCashPointsByLocationAndName(location, "Test", true); Assert.assertNotNull(results1); Assert.assertEquals(3, results1.size()); Assert.assertEquals(0, (int) Iterators.get(results1.iterator(), 0).getId()); }
@Override public CashPoint createEntity(boolean valid) { CashPoint cashPoint = new CashPoint(); if (valid) { cashPoint.setName("Test Cash Point"); } cashPoint.setDescription("Test description"); cashPoint.setLocation(Context.getLocationService().getLocation(1)); cashPoint.setCreator(Context.getAuthenticatedUser()); cashPoint.setDateCreated(new Date()); return cashPoint; }
@Override protected void updateEntityFields(CashPoint cashPoint) { cashPoint.setName(cashPoint.getName() + " updated"); cashPoint.setDescription(cashPoint.getDescription() + " updated"); cashPoint.setLocation(Context.getLocationService().getLocation(0)); }