From 0bc198764cd527e97b1d42d7c23e53d32040fe17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michae=CC=88l=20van=20de=20Giessen?= Date: Tue, 19 Jun 2018 08:03:38 +0200 Subject: [PATCH] feedback formatting, test, avoid inline if (bunq/sdk_java#93) at the cost of risk for index-out-of-bounds (prior code) --- .../java/com/bunq/sdk/model/core/UserContextHelper.java | 2 +- src/test/java/com/bunq/sdk/context/UserContextTest.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/bunq/sdk/model/core/UserContextHelper.java b/src/main/java/com/bunq/sdk/model/core/UserContextHelper.java index 7fd1c286..036726b7 100644 --- a/src/main/java/com/bunq/sdk/model/core/UserContextHelper.java +++ b/src/main/java/com/bunq/sdk/model/core/UserContextHelper.java @@ -31,7 +31,7 @@ public User getFirstUser() { BunqResponseRaw responseRaw = getRawResponse(USER_URL); BunqResponse> response = fromJsonList(User.class, responseRaw); - return !response.getValue().isEmpty()?response.getValue().get(FIRST):null; + return response.getValue().get(FIRST); } public MonetaryAccountBank getFirstActiveMonetaryAccountBankByUserId(Integer userId) { diff --git a/src/test/java/com/bunq/sdk/context/UserContextTest.java b/src/test/java/com/bunq/sdk/context/UserContextTest.java index 2304d9e9..3aba594b 100644 --- a/src/test/java/com/bunq/sdk/context/UserContextTest.java +++ b/src/test/java/com/bunq/sdk/context/UserContextTest.java @@ -8,12 +8,13 @@ public class UserContextTest extends BunqSdkTestBase { @Test - public void testConstruct() { + public void buildUserContext() { ApiContext context = getApiContext(); - UserContext sut = new UserContext(context); + UserContext userContext = new UserContext(context); - assertNotNull(sut.getUserId()); - assertNotNull(sut.getMainMonetaryAccountId()); + assertNotNull(userContext.getUserId()); + assertNotNull(userContext.getMainMonetaryAccountId()); } } +