Minor refactorings and code style changes (#807)

* Made minor changes in some patterns such as removed throws clause where not needed, changed incorrect order of arguments in assertEquals

* Minor refactorings and code style changes. 1) Removed several use of raw types 2) Removed unnecessary throws clauses 3) Used lambda expressions wherever applicable 4) Used apt assertion methods for readability 5) Use of try with resources wherever applicable 6) Corrected incorrect order of assertXXX arguments

* Removed unused import from Promise

* Addressed review comments

* Addressed checkstyle issue
This commit is contained in:
Narendra Pathai
2018-10-23 13:45:41 +05:30
committed by GitHub
parent 25ed7c09c5
commit 2aa9e78ddd
112 changed files with 312 additions and 463 deletions

View File

@ -31,7 +31,7 @@ import java.io.IOException;
*/
public class AppTest {
@Test
public void test() throws IOException {
public void test() {
String[] args = {};
App.main(args);
}

View File

@ -37,16 +37,16 @@ public class FruitBowlTest {
public void fruitBowlTest() {
FruitBowl fbowl = new FruitBowl();
assertEquals(fbowl.countFruit(), 0);
assertEquals(0, fbowl.countFruit());
for (int i = 1; i <= 10; i++) {
fbowl.put(new Fruit(Fruit.FruitType.LEMON));
assertEquals(fbowl.countFruit(), i);
assertEquals(i, fbowl.countFruit());
}
for (int i = 9; i >= 0; i--) {
assertNotNull(fbowl.take());
assertEquals(fbowl.countFruit(), i);
assertEquals(i, fbowl.countFruit());
}
assertNull(fbowl.take());

View File

@ -36,12 +36,12 @@ public class SemaphoreTest {
public void acquireReleaseTest() {
Semaphore sphore = new Semaphore(3);
assertEquals(sphore.getAvailableLicenses(), 3);
assertEquals(3, sphore.getAvailableLicenses());
for (int i = 2; i >= 0; i--) {
try {
sphore.acquire();
assertEquals(sphore.getAvailableLicenses(), i);
assertEquals(i, sphore.getAvailableLicenses());
} catch (InterruptedException e) {
fail(e.toString());
}
@ -49,10 +49,10 @@ public class SemaphoreTest {
for (int i = 1; i <= 3; i++) {
sphore.release();
assertEquals(sphore.getAvailableLicenses(), i);
assertEquals(i, sphore.getAvailableLicenses());
}
sphore.release();
assertEquals(sphore.getAvailableLicenses(), 3);
assertEquals(3, sphore.getAvailableLicenses());
}
}