@Override public HouseholdImpl createHousehold(Id<Household> householdId) { HouseholdImpl hh = new HouseholdImpl(householdId); hh.setMemberIds(new ArrayList<Id<Person>>()); hh.setVehicleIds(new ArrayList<Id<Vehicle>>()); return hh; }
private void fillHousehold() { ((HouseholdImpl) this.currentHousehold).setMemberIds(this.currentmembers); ((HouseholdImpl) this.currentHousehold).setVehicleIds(this.currentVehicleIds); this.currentHousehold.setIncome(this.currentincome); this.currentHhId = null; this.currentVehicleIds = null; this.currentincome = null; this.currentmembers = null; this.currentIncomePeriod = null; this.currentincomeCurrency = null; }
/** * Test that households are accumulated if streaming is off. */ public void testAddHousehold_NoStreaming(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("2", Household.class)); hhs.addHousehold(hh1); assertEquals("Should have the first household added.", 1, hhs.getHouseholds().size()); assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); hhs.addHousehold(hh2); assertEquals("Should have the first AND second household added.", 2, hhs.getHouseholds().size()); assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); assertTrue("Second household not present.", hhs.getHouseholds().containsValue(hh2)); }
/*package*/ Household createHousehold() { Household hh = this.builder.createHousehold(this.currentHhId); ((HouseholdImpl) hh).setMemberIds(this.currentmembers); ((HouseholdImpl) hh).setVehicleIds(this.currentVehicleIds); hh.setIncome(this.currentincome); this.currentHhId = null; this.currentVehicleIds = null; this.currentincome = null; this.currentmembers = null; this.currentIncomePeriod = null; this.currentincomeCurrency = null; return hh; }
/** * Test that households with the same {@link Id} are not accepted. */ public void testAddHousehold_DuplicateId(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("1", Household.class)); assertEquals("Shouldn't have a household.", 0, hhs.getHouseholds().size()); hhs.addHousehold(hh1); assertEquals("Didn't add the household.", 1, hhs.getHouseholds().size()); assertEquals("Should have added the household.", hh1, hhs.getHouseholds().get(hh1.getId())); try{ hhs.addHousehold(hh2); fail("Should not have accepted household with similar Id."); } catch (IllegalArgumentException e){ } }