* remove else condition

* remove else condition

* spring retry introduction

* remove else condition

* remove spring retry, format code
This commit is contained in:
Tuan 2016-12-02 05:46:56 +07:00 committed by Zeger Hendrikse
parent 5750a3a064
commit 6df8e9000e
3 changed files with 11 additions and 10 deletions

View File

@ -98,13 +98,14 @@
<execution> <execution>
<goals> <goals>
<goal>compile</goal> <goal>compile</goal>
<goal>test-compile</goal> <goal>test-compile</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- <plugin> <!--
<plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version> <version>2.10</version>
@ -113,7 +114,8 @@
<useSystemClassLoader>true</useSystemClassLoader> <useSystemClassLoader>true</useSystemClassLoader>
<forkMode>always</forkMode> <forkMode>always</forkMode>
</configuration> </configuration>
</plugin> --> </plugin>
-->
</plugins> </plugins>
</build> </build>

View File

@ -4,10 +4,10 @@ public class Account {
int balance = 20; int balance = 20;
public boolean withdraw(int amount) { public boolean withdraw(int amount) {
if (balance - amount > 0) { if (balance < amount) {
balance = balance - amount;
return true;
} else
return false; return false;
}
balance = balance - amount;
return true;
} }
} }

View File

@ -16,12 +16,11 @@ public aspect AccountAspect {
} }
boolean around(int amount, Account account) : callWithDraw(amount, account) { boolean around(int amount, Account account) : callWithDraw(amount, account) {
if (account.balance - amount >= MIN_BALANCE) if (account.balance < amount) {
return proceed(amount, account);
else {
logger.info("Withdrawal Rejected!"); logger.info("Withdrawal Rejected!");
return false; return false;
} }
return proceed(amount, account);
} }
after(int amount, Account balance) : callWithDraw(amount, balance) { after(int amount, Account balance) : callWithDraw(amount, balance) {