p4.setGivenname("p4");
p4.setMail("p4@mail.com");
p4.setSurname("p4");
Budget budget = new Budget();
budget.setCurrency("euro");
Map<String,Float> change = new HashMap<String,Float>(2);
change.put("USD",(float)2.0);
change.put("YEN",(float)4.0);
budget.setChange(change);
budget.addPerson(p1);
budget.addPerson(p2);
budget.addPerson(p3);
budget.addPerson(p4);
Expenditure exp1 = new Expenditure();
exp1.setOwner(p1);
exp1.addRecipient(p1, 1); // p1 : 0
exp1.addRecipient(p2, 2); // p2 : -200 / p1 : +200
exp1.setAmount(300);
Expenditure exp2 = new Expenditure();
exp2.setOwner(p3);
exp2.addRecipient(p2, 1); // p2 : -40 / p3 : + 40
exp2.addRecipient(p3, 1); // p3 : 0
exp2.setAmount(20); // 20 YEN * 4 = 80 EUR
exp2.setCurrency("YEN");
Expenditure exp3 = new Expenditure();
exp3.setOwner(p1);
exp3.addRecipient(p1, 1); // p1 : 0
exp3.addRecipient(p2, 1); // p2 : -100 / p1 : +100
exp3.addRecipient(p3, 1); // p3 : -100 / p1 : +100
exp3.setAmount(300);
Expenditure exp4 = new Expenditure();
exp4.setOwner(p2);
exp4.addRecipient(p2, 1); // p2 : 0
exp4.addRecipient(p3, 1); // p3 : -100 / p2 : +100
exp4.addRecipient(p1, 2); // p1 : -200 / p2 : +200
exp4.setAmount(400);
Expenditure exp5 = new Expenditure();
exp5.setOwner(p4);
exp5.addRecipient(p2, 1); // p2 : -50 / p4 : +50
exp5.addRecipient(p1, 1); // p1 : -50 / p4 : +50
exp5.addRecipient(p3, 1); // p3 : -50 / p4 : +50
exp5.addRecipient(p4, 1); // p4 : 0
exp5.setAmount(200);
Expenditure exp6 = new Expenditure();
exp6.setOwner(p3);
exp6.addRecipient(p1, 2); // p1 : -80 / p3 : +80
exp6.addRecipient(p4, 1); // p4 : -40 / p3 : +40
exp6.setAmount(60);
exp6.setCurrency("USD");
// Total:
// p1 : +70
// p2 : -90
// p3 : -90
// p4 : +110
try {
budget.addExpenditure(exp1);
budget.addExpenditure(exp2);
budget.addExpenditure(exp3);
budget.addExpenditure(exp4);
budget.addExpenditure(exp5);
budget.addExpenditure(exp6);
BudgetService bs = new BudgetService(new AdjacencyMatrixGraphFactory());
Graph graph = bs.resolveBudget(budget);
assertEquals(graph.getVertexSet().size(), 4);