Skip to content

Commit 5eb67ad

Browse files
committed
Improve Credit Pool tests
1 parent 6a62054 commit 5eb67ad

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/main/java/com/exaroton/api/billing/pools/CreditPoolMember.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
package com.exaroton.api.billing.pools;
22

3-
import org.jetbrains.annotations.ApiStatus;
4-
3+
@SuppressWarnings("unused")
54
public class CreditPoolMember {
65
/**
76
* Unique ID of the account
87
*/
9-
private final String account;
8+
private String account;
109
/**
1110
* Unique (but changeable) display name of the account.
1211
*/
13-
private final String name;
12+
private String name;
1413
/**
1514
* The share of credits in the pool that belong to the account.
1615
* e.g. 0.5 means the account owns 50% of the credits in the pool.
1716
*/
18-
private final double share;
17+
private double share;
1918
/**
2019
* The amount of credits in the pool that belong to the account.
2120
*/
22-
private final double credits;
21+
private double credits;
2322
/**
2423
* Is the account the owner of the pool
2524
*/
26-
private final boolean isOwner;
27-
28-
@ApiStatus.Internal
29-
public CreditPoolMember(String account, String name, double share, double credits, boolean isOwner) {
30-
this.account = account;
31-
this.name = name;
32-
this.share = share;
33-
this.credits = credits;
34-
this.isOwner = isOwner;
35-
}
25+
private boolean isOwner;
3626

3727
/**
3828
* @return unique ID of the account

src/test/java/CreditPoolsTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ public void testGetPool() throws IOException {
3838
checkTestPool(pool);
3939
}
4040

41+
@Test
42+
public void testGetPoolCache() throws IOException {
43+
CreditPool pool = client.getCreditPool(TEST_POOL_ID);
44+
45+
var future = pool.fetch(false);
46+
Assertions.assertFalse(future.isDone());
47+
Assertions.assertNull(future.getNow(null));
48+
49+
checkTestPool(pool.fetch().join());
50+
checkTestPool(pool);
51+
52+
future = pool.fetch(false);
53+
Assertions.assertTrue(future.isDone());
54+
checkTestPool(future.getNow(null));
55+
}
56+
4157
@Test
4258
public void testGetPoolMembers() throws IOException {
4359
CreditPool pool = client.getCreditPool(TEST_POOL_ID);
@@ -48,6 +64,7 @@ public void testGetPoolMembers() throws IOException {
4864
Optional<CreditPoolMember> owner = members.stream().filter(CreditPoolMember::isOwner).findFirst();
4965
Assertions.assertTrue(owner.isPresent());
5066
Assertions.assertNotNull(owner.get().getAccount());
67+
Assertions.assertNotNull(owner.get().getName());
5168
Assertions.assertTrue(owner.get().isOwner());
5269
Assertions.assertTrue(owner.get().getCredits() > 100, "Expected owner to have more than 100 credits, got " + owner.get().getCredits());
5370
Assertions.assertEquals(1, owner.get().getShare());

0 commit comments

Comments
 (0)