Example #1
0
 @Test
 public void partWithOneDebtNoUnit() {
   final Donation donation =
       new Donation("test", getRnD(), getBob(), getEuro(), BigDecimal.TEN, 0);
   new Debt(getBob(), donation, 1);
   assertEquals(BigDecimal.TEN, donation.getPartCost());
 }
Example #2
0
 @Test
 public void partWithTwoDebtsNoUnit() {
   final Donation donation =
       new Donation("test", getRnD(), getBob(), getEuro(), BigDecimal.TEN, 0);
   new Debt(getBob(), donation, 2);
   assertEquals(2, donation.getTakenUnit());
   assertEquals(BigDecimal.valueOf(5), donation.getPartCost());
 }
 public static long[] getGoalPercentage(Long eventId, int eventGoal) {
   long total[] = new long[3];
   total[0] = models.Donation.getTotalEventDonations(eventId);
   if (total[0] == 0 || eventGoal == 0) {
     total[1] = 0;
     total[2] = 0;
     return total;
   }
   final int percentage = Long.valueOf((total[0] * 100) / eventGoal).intValue();
   if (percentage > 150) {
     total[2] = 150;
   } else if (percentage < 10) {
     total[2] = 1;
   } else {
     total[2] = round(percentage);
   }
   total[1] = percentage;
   return total;
 }
Example #4
0
 @Test
 public void partCost() {
   final Donation donation =
       new Donation("test", getRnD(), getBob(), getEuro(), BigDecimal.TEN, 10);
   assertEquals(BigDecimal.ONE, donation.getPartCost());
 }
Example #5
0
 @Test
 public void partCostForFreeDonation() {
   final Donation donation = new Donation("test", getRnD(), getBob(), getEuro(), null, 0);
   assertEquals(BigDecimal.ZERO, donation.getPartCost());
 }