@Test(expected = RankingConstraintException.class) @SuppressWarnings("unused") public void testRanking() { Company c = new Company(); Department d1 = new Department(); Department subD1 = new Department(); d1.getSubdepts().add(subD1); subD1.setParent(d1); c.getDepts().add(d1); Employee e1 = service.createEmployee("E1", "E1addr", 30000.0, d1); // this should fail, because sub dept employees aren't allowed to earn more then their higher // colleagues Employee e2 = service.createEmployee("E2", "E2addr", 31000.0, subD1); }
public Double visit(Company o) { double total = 0; for (Department d : o.getDepts()) total += d.accept(this); return total; }
static void getEmployees(Set<Employee> employees, Company c) { for (Department d : c.getDepts()) { getEmployees(employees, d); } }