FinancingRoundEntity { public void initPostRoundBudget(int pledgeAmountByUsers) { if (!this.terminated()) { throw new IllegalStateException("Cannot initialize remaining budget on not yet terminated financing round: " + this); } if (this.postRoundBudget != null) { throw new IllegalStateException("PostRoundBudget must not be initialized more than once!"); } int budgetRemainingAfterRound = getBudget() - pledgeAmountByUsers; if (budgetRemainingAfterRound < 0) { log.warn("It seems, within this financing round there were more pledges done than budget available; Setting remaining budget to 0; " + "The pledge amount above budget is: {}; FinancingRound was: {}", budgetRemainingAfterRound, this); budgetRemainingAfterRound = 0; } setPostRoundBudget(budgetRemainingAfterRound); } FinancingRoundEntity(); static FinancingRoundEntity newFinancingRound(FinancingRound creationCmd, int userCount); boolean projectEligibleForRound(ProjectEntity project); void stopFinancingRound(); boolean active(); boolean terminated(); boolean terminationPostProcessingRequiredNow(); Integer postRoundPledgableBudgetRemaining(List<PledgeEntity> postRoundPledges); void initPostRoundBudget(int pledgeAmountByUsers); String getId(); DateTime getStartDate(); DateTime getEndDate(); Integer getBudget(); Integer getBudgetPerUser(); Integer getUserCount(); DateTime getCreatedDate(); DateTime getLastModifiedDate(); Boolean getTerminationPostProcessingDone(); Integer getPostRoundBudget(); void setId(String id); void setStartDate(DateTime startDate); void setEndDate(DateTime endDate); void setBudget(Integer budget); void setBudgetPerUser(Integer budgetPerUser); void setUserCount(Integer userCount); void setCreatedDate(DateTime createdDate); void setLastModifiedDate(DateTime lastModifiedDate); void setTerminationPostProcessingDone(Boolean terminationPostProcessingDone); void setPostRoundBudget(Integer postRoundBudget); @Override boolean equals(Object o); boolean idenitityEquals(FinancingRoundEntity other); @Override int hashCode(); @Override String toString();  }
@Test public void initPostRoundBudget() throws Exception { final FinancingRoundEntity financingRound = newFinancingRound(1000, 10, new DateTime().minusHours(1)); financingRound.initPostRoundBudget(17); assertThat(financingRound.getPostRoundBudget(), is(983)); }