diff --git a/pom.xml b/pom.xml index a7a71930..cda191c4 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,9 @@ **/ProductionLiquibaseRunner.java, **/TestLiquibaseRunner.java + e1 + java:S6813 + **/ukelonn.web.services/src/main/java/**/resources/*.java ${project.basedir}/../jacoco-coverage-report/target/site/jacoco-aggregate/jacoco.xml diff --git a/ukelonn.backend/src/main/java/no/priv/bang/ukelonn/backend/UkelonnServiceProvider.java b/ukelonn.backend/src/main/java/no/priv/bang/ukelonn/backend/UkelonnServiceProvider.java index fa040130..59d32d94 100644 --- a/ukelonn.backend/src/main/java/no/priv/bang/ukelonn/backend/UkelonnServiceProvider.java +++ b/ukelonn.backend/src/main/java/no/priv/bang/ukelonn/backend/UkelonnServiceProvider.java @@ -119,7 +119,7 @@ public LogService getLogservice() { public List getAccounts() { var accounts = new ArrayList(); try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from accounts_view")) { + try(var statement = connection.prepareStatement("select account_id, username, balance from accounts_view")) { try(var results = statement.executeQuery()) { if (results != null) { while(results.next()) { @@ -140,7 +140,7 @@ public List getAccounts() { @Override public Account getAccount(String username) { try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from accounts_view where username=?")) { + try(var statement = connection.prepareStatement("select account_id, username, balance from accounts_view where username=?")) { statement.setString(1, username); try(var resultset = statement.executeQuery()) { if (resultset.next()) @@ -183,7 +183,7 @@ public Account registerPerformedJob(PerformedTransaction job) { public List getJobTypes() { var jobtypes = new ArrayList(); try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from transaction_types where transaction_is_work=true")) { + try(var statement = connection.prepareStatement("select transaction_type_id, transaction_type_name, transaction_amount, transaction_is_work, transaction_is_wage_payment from transaction_types where transaction_is_work=true")) { try(var resultSet = statement.executeQuery()) { if (resultSet != null) { while (resultSet.next()) { @@ -286,7 +286,7 @@ public List updateJob(UpdatedTransaction editedJob) { public List getPaymenttypes() { var paymenttypes = new ArrayList(); try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from transaction_types where transaction_is_wage_payment=true")) { + try(var statement = connection.prepareStatement("select transaction_type_id, transaction_type_name, transaction_amount, transaction_is_work, transaction_is_wage_payment from transaction_types where transaction_is_wage_payment=true")) { try(var resultSet = statement.executeQuery()) { if (resultSet != null) { while (resultSet.next()) { @@ -483,7 +483,7 @@ public void notificationTo(String username, Notification notification) { public List getActiveBonuses() { var activebonuses = new ArrayList(); try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from bonuses where enabled and start_date <= ? and end_date >= ?")) { + try(var statement = connection.prepareStatement("select bonus_id, enabled, iconurl, title, description, bonus_factor, start_date, end_date from bonuses where enabled and start_date <= ? and end_date >= ?")) { var today = Timestamp.from(new Date().toInstant()); statement.setTimestamp(1, today); statement.setTimestamp(2, today); @@ -504,7 +504,7 @@ public List getActiveBonuses() { public List getAllBonuses() { var allbonuses = new ArrayList(); try(var connection = datasource.getConnection()) { - try(var statement = connection.prepareStatement("select * from bonuses")) { + try(var statement = connection.prepareStatement("select bonus_id, enabled, iconurl, title, description, bonus_factor, start_date, end_date from bonuses")) { try (var results = statement.executeQuery()) { while (results.next()) { buildBonusFromResultSetAndAddToList(allbonuses, results); diff --git a/ukelonn.backend/src/test/java/no/priv/bang/ukelonn/backend/UkelonnServiceProviderTest.java b/ukelonn.backend/src/test/java/no/priv/bang/ukelonn/backend/UkelonnServiceProviderTest.java index de2b2bce..48db6ed2 100644 --- a/ukelonn.backend/src/test/java/no/priv/bang/ukelonn/backend/UkelonnServiceProviderTest.java +++ b/ukelonn.backend/src/test/java/no/priv/bang/ukelonn/backend/UkelonnServiceProviderTest.java @@ -32,8 +32,6 @@ import java.util.List; import java.util.Locale; import java.util.Optional; -import java.util.stream.Collectors; - import javax.sql.DataSource; import org.junit.jupiter.api.AfterAll; @@ -696,7 +694,7 @@ void testUpdateJob() throws Exception { var updatedJobs = ukelonn.updateJob(editedJob); - var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).collect(Collectors.toList()).get(0); + var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).toList().get(0); assertEquals(editedJob.transactionTypeId(), editedJobFromDatabase.transactionType().id()); assertThat(editedJobFromDatabase.transactionTime().getTime()).isGreaterThan(originalTransactionTime.getTime()); @@ -725,7 +723,7 @@ void testUpdateJobGetSQLException() throws Exception { } private TransactionType findJobTypeWithDifferentIdAndAmount(UkelonnService ukelonn, Integer transactionTypeId, double amount) { - return ukelonn.getJobTypes().stream().filter(t->t.id() != transactionTypeId).filter(t->t.transactionAmount() != amount).collect(Collectors.toList()).get(0); + return ukelonn.getJobTypes().stream().filter(t->t.id() != transactionTypeId).filter(t->t.transactionAmount() != amount).toList().get(0); } @Test @@ -1196,7 +1194,7 @@ void testJoinIds() { var ukelonn = getUkelonnServiceSingleton(); ukelonn.setUserAdmin(useradmin); var account = ukelonn.getAccount("jad"); - var jobs = ukelonn.getJobs(account.accountId()).stream().map(Transaction::id).collect(Collectors.toList()); + var jobs = ukelonn.getJobs(account.accountId()).stream().map(Transaction::id).toList(); assertEquals("31, 33, 34, 35, 37, 38, 39, 41, 42, 43", UkelonnServiceProvider.joinIds(jobs).toString()); } diff --git a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/LocaleBean.java b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/LocaleBean.java index 018d27bd..42ca9e60 100644 --- a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/LocaleBean.java +++ b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/LocaleBean.java @@ -15,8 +15,9 @@ */ package no.priv.bang.ukelonn.beans; +import static java.util.Optional.ofNullable; + import java.util.Locale; -import java.util.Optional; public record LocaleBean(String code, String displayLanguage) { @@ -30,9 +31,9 @@ public static class Builder { private Builder() {} public LocaleBean build() { - String locale = Optional.ofNullable(this.locale).map(l -> l.toString()).orElse(null); - String displayLanguage = Optional.ofNullable(this.locale).map(l -> l.getDisplayLanguage(l)).orElse(null); - return new LocaleBean(locale, displayLanguage); + var localeCode = ofNullable(this.locale).map(Object::toString).orElse(null); + var displayLanguage = ofNullable(this.locale).map(l -> l.getDisplayLanguage(l)).orElse(null); + return new LocaleBean(localeCode, displayLanguage); } public Builder locale(Locale locale) { diff --git a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/PerformedTransaction.java b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/PerformedTransaction.java index 2de1c319..c2919d6b 100644 --- a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/PerformedTransaction.java +++ b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/PerformedTransaction.java @@ -34,10 +34,11 @@ public static class Builder { private Builder() {} public PerformedTransaction build() { - var transactionTypeId = ofNullable(this.transactionTypeId).orElse(-1); - var transactionAmount = ofNullable(this.transactionAmount).orElse(0.0); - var transactionDate = ofNullable(this.transactionDate).orElse(new Date()); - return new PerformedTransaction(this.account, transactionTypeId, transactionAmount, transactionDate); + return new PerformedTransaction( + this.account, + ofNullable(this.transactionTypeId).orElse(-1), + ofNullable(this.transactionAmount).orElse(0.0), + ofNullable(this.transactionDate).orElse(new Date())); } public Builder account(Account account) { diff --git a/ukelonn.testutils/src/main/java/no/priv/bang/ukelonn/testutils/TestUtils.java b/ukelonn.testutils/src/main/java/no/priv/bang/ukelonn/testutils/TestUtils.java index 0775a765..9f8d8708 100644 --- a/ukelonn.testutils/src/main/java/no/priv/bang/ukelonn/testutils/TestUtils.java +++ b/ukelonn.testutils/src/main/java/no/priv/bang/ukelonn/testutils/TestUtils.java @@ -185,7 +185,7 @@ public static TransactionType copyTransactionType(TransactionType transactiontyp } public static List copyTransactiontypes(List transactiontypes) { - return transactiontypes.stream().map(transactiontype -> copyTransactionType(transactiontype)).collect(Collectors.toList()); + return transactiontypes.stream().map(transactiontype -> copyTransactionType(transactiontype)).toList(); } public static Transaction convertUpdatedTransaction(UpdatedTransaction transaction) { @@ -202,7 +202,7 @@ public static Transaction copyTransaction(Transaction transaction) { } public static List copyTransactions(List transactions) { - return transactions.stream().map(transaction -> copyTransaction(transaction)).collect(Collectors.toList()); + return transactions.stream().map(transaction -> copyTransaction(transaction)).toList(); } public static List getJobtypes() { @@ -242,7 +242,7 @@ public static List getJodJobs() { } public static List getFirstJodJob() { - return jodJobs.stream().limit(1).collect(Collectors.toList()); + return jodJobs.stream().limit(1).toList(); } public static List getDummyAccounts() { diff --git a/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/beans/LoginResult.java b/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/beans/LoginResult.java index f72b6fdb..c99a4adb 100644 --- a/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/beans/LoginResult.java +++ b/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/beans/LoginResult.java @@ -15,7 +15,11 @@ */ package no.priv.bang.ukelonn.api.beans; -public record LoginResult(String username, String[] roles, String errorMessage) { +import static java.util.Collections.*; + +import java.util.List; + +public record LoginResult(String username, List roles, String errorMessage) { public static Builder with() { return new Builder(); @@ -23,7 +27,7 @@ public static Builder with() { public static class Builder { private String username = ""; - private String[] roles = {}; + private List roles = emptyList(); private String errorMessage = ""; private Builder() {} @@ -37,7 +41,7 @@ public Builder username(String username) { return this; } - public Builder roles(String[] roles) { + public Builder roles(List roles) { this.roles = roles; return this; } diff --git a/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/resources/Login.java b/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/resources/Login.java index 5a6b2af0..901aaba3 100644 --- a/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/resources/Login.java +++ b/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/resources/Login.java @@ -15,6 +15,7 @@ */ package no.priv.bang.ukelonn.api.resources; +import java.util.Arrays; import java.util.Base64; import javax.inject.Inject; @@ -104,7 +105,7 @@ private LoginResult createLoginResultFromSubject(Subject subject) { var username = (String) subject.getPrincipal(); return LoginResult.with() .username(username) - .roles(roles) + .roles(Arrays.asList(roles)) .build(); } diff --git a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/UkelonnRestApiServletTest.java b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/UkelonnRestApiServletTest.java index 031427ed..3004bcc1 100644 --- a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/UkelonnRestApiServletTest.java +++ b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/UkelonnRestApiServletTest.java @@ -29,7 +29,6 @@ import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.servlet.ServletConfig; @@ -196,7 +195,7 @@ void testLoginUnknownUser() throws Exception { assertEquals("application/json", response.getContentType()); var result = ServletTestBase.mapper.readValue(response.getOutputStreamContent(), LoginResult.class); - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Unknown account", result.errorMessage()); } @@ -231,7 +230,7 @@ void testLoginWrongPassword() throws Exception { assertEquals("application/json", response.getContentType()); var result = ServletTestBase.mapper.readValue(response.getOutputStreamContent(), LoginResult.class); - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Wrong password", result.errorMessage()); } @@ -336,7 +335,7 @@ void testGetLoginStateWhenNotLoggedIn() throws Exception { assertEquals("application/json", response.getContentType()); var result = ServletTestBase.mapper.readValue(response.getOutputStreamContent(), LoginResult.class); - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } @@ -366,7 +365,7 @@ void testLogoutOk() throws Exception { assertEquals("application/json", response.getContentType()); var result = ServletTestBase.mapper.readValue(response.getOutputStreamContent(), LoginResult.class); - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } @@ -401,7 +400,7 @@ void testLogoutNotLoggedIn() throws Exception { assertEquals("application/json", response.getContentType()); var result = ServletTestBase.mapper.readValue(response.getOutputStreamContent(), LoginResult.class); - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } @@ -928,7 +927,7 @@ void testUpdateJob() throws Exception { assertEquals(200, response.getStatus()); assertEquals("application/json", response.getContentType()); var updatedJobs = mapper.readValue(getBinaryContent(response), new TypeReference>() { }); - var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).collect(Collectors.toList()).get(0); + var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).toList().get(0); assertEquals(editedJob.transactionTypeId(), editedJobFromDatabase.transactionType().id()); assertThat(editedJobFromDatabase.transactionTime().getTime()).isGreaterThan(job.transactionTime().getTime()); @@ -1105,7 +1104,7 @@ void testCreateJobtype() throws Exception { var logservice = new MockLogService(); var useradmin = mock(UserManagementService.class); var ukelonn = mock(UkelonnService.class); - var updatedjobtypes = Stream.concat(originalJobtypes.stream(), Stream.of(jobtype)).collect(Collectors.toList()); + var updatedjobtypes = Stream.concat(originalJobtypes.stream(), Stream.of(jobtype)).toList(); when(ukelonn.createJobtype(any())).thenReturn(updatedjobtypes); var servlet = simulateDSComponentActivationAndWebWhiteboardConfiguration(ukelonn, logservice, useradmin); @@ -1191,7 +1190,7 @@ void testCreatePaymenttype() throws Exception { var logservice = new MockLogService(); var useradmin = mock(UserManagementService.class); var ukelonn = mock(UkelonnService.class); - var updatedpaymenttypes = Stream.concat(originalPaymenttypes.stream(), Stream.of(paymenttype)).collect(Collectors.toList()); + var updatedpaymenttypes = Stream.concat(originalPaymenttypes.stream(), Stream.of(paymenttype)).toList(); when(ukelonn.createPaymenttype(any())).thenReturn(updatedpaymenttypes); var servlet = simulateDSComponentActivationAndWebWhiteboardConfiguration(ukelonn, logservice, useradmin); @@ -1326,7 +1325,7 @@ void testCreateUser() throws Exception { var logservice = new MockLogService(); var ukelonn = mock(UkelonnService.class); var useradmin = mock(UserManagementService.class); - var updatedusers = Stream.concat(getUsersForUserManagement().stream(), Stream.of(user)).collect(Collectors.toList()); + var updatedusers = Stream.concat(getUsersForUserManagement().stream(), Stream.of(user)).toList(); when(useradmin.addUser(any())).thenReturn(updatedusers); var servlet = simulateDSComponentActivationAndWebWhiteboardConfiguration(ukelonn, logservice, useradmin); @@ -1855,7 +1854,7 @@ void testDefaultLocale() throws Exception { void testAvailableLocales() throws Exception { // Set up REST API servlet with mocked services var ukelonn = mock(UkelonnService.class); - when(ukelonn.availableLocales()).thenReturn(Collections.singletonList(Locale.forLanguageTag("nb-NO")).stream().map(l -> LocaleBean.with().locale(l).build()).collect(Collectors.toList())); + when(ukelonn.availableLocales()).thenReturn(Collections.singletonList(Locale.forLanguageTag("nb-NO")).stream().map(l -> LocaleBean.with().locale(l).build()).toList()); var logservice = new MockLogService(); var useradmin = mock(UserManagementService.class); @@ -1931,7 +1930,7 @@ void testDisplayTextsWithUnknownLocale() throws Exception { } private TransactionType findJobTypeWithDifferentIdAndAmount(Integer transactionTypeId, double amount) { - return getJobtypes().stream().filter(t->t.id() != transactionTypeId).filter(t->t.transactionAmount() != amount).collect(Collectors.toList()).get(0); + return getJobtypes().stream().filter(t->t.id() != transactionTypeId).filter(t->t.transactionAmount() != amount).toList().get(0); } diff --git a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/JobResourceTest.java b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/JobResourceTest.java index 952759a4..35f2b4aa 100644 --- a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/JobResourceTest.java +++ b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/JobResourceTest.java @@ -26,8 +26,6 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.Date; -import java.util.stream.Collectors; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -297,7 +295,7 @@ void testUpdateJob() { var updatedJobs = resource.doUpdateJob(editedJob); - var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).collect(Collectors.toList()).get(0); + var editedJobFromDatabase = updatedJobs.stream().filter(t->t.id() == job.id()).toList().get(0); assertEquals(editedJob.transactionTypeId(), editedJobFromDatabase.transactionType().id()); assertThat(editedJobFromDatabase.transactionTime().getTime()).isGreaterThan(originalTransactionTime.getTime()); @@ -327,7 +325,7 @@ void testUpdateJobGetSQLException() throws Exception { } private TransactionType findJobTypeWithDifferentIdAndAmount(UkelonnService ukelonn, Integer transactionTypeId, double amount) { - return getJobtypes().stream().filter(t->!(t.id() == transactionTypeId)).filter(t->t.transactionAmount() != amount).collect(Collectors.toList()).get(0); + return getJobtypes().stream().filter(t->!(t.id() == transactionTypeId)).filter(t->t.transactionAmount() != amount).toList().get(0); } } diff --git a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LocalizationResourceTest.java b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LocalizationResourceTest.java index 115a3f68..e963c460 100644 --- a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LocalizationResourceTest.java +++ b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LocalizationResourceTest.java @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.MissingResourceException; -import java.util.stream.Collectors; - import javax.ws.rs.WebApplicationException; import static org.assertj.core.api.Assertions.assertThat; @@ -50,7 +48,7 @@ void testDefaultLocale() { void testAvailableLocales() { var ukelonn = mock(UkelonnService.class); when(ukelonn.defaultLocale()).thenReturn(NB_NO); - when(ukelonn.availableLocales()).thenReturn(Arrays.asList(Locale.forLanguageTag("nb-NO"), Locale.UK).stream().map(l -> LocaleBean.with().locale(l).build()).collect(Collectors.toList())); + when(ukelonn.availableLocales()).thenReturn(Arrays.asList(Locale.forLanguageTag("nb-NO"), Locale.UK).stream().map(l -> LocaleBean.with().locale(l).build()).toList()); var resource = new LocalizationResource(); resource.ukelonn = ukelonn; var availableLocales = resource.availableLocales(); diff --git a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LoginTest.java b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LoginTest.java index 9d26e00d..4a4fd1e9 100644 --- a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LoginTest.java +++ b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LoginTest.java @@ -117,7 +117,7 @@ void testLoginUnknownUser() throws Exception { LoginResult result = resource.doLogin(credentials); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Unknown account", result.errorMessage()); } @@ -142,7 +142,7 @@ void testLoginWrongPassword() throws Exception { LoginResult result = resource.doLogin(credentials); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Wrong password", result.errorMessage()); } @@ -166,7 +166,7 @@ void testLoginLockedAccount() throws Exception { createSubjectAndBindItToThread(request, response); LoginResult result = resource.doLogin(credentials); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Locked account", result.errorMessage()); } finally { unlockAccount("jad"); @@ -187,7 +187,7 @@ void testLoginWithAuthenticationException() { resource.setLogservice(logservice); LoginResult result = resource.doLogin(credentials); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("Unknown error", result.errorMessage()); } @@ -271,7 +271,7 @@ void testGetLoginStateWhenNotLoggedIn() throws Exception { LoginResult result = resource.loginStatus(); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } diff --git a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LogoutTest.java b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LogoutTest.java index 8172c33a..3aeac9ab 100644 --- a/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LogoutTest.java +++ b/ukelonn.web.services/src/test/java/no/priv/bang/ukelonn/api/resources/LogoutTest.java @@ -15,6 +15,7 @@ */ package no.priv.bang.ukelonn.api.resources; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -53,7 +54,7 @@ void testLogoutOk() throws Exception { var result = resource.doLogout(); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } @@ -80,7 +81,7 @@ void testLogoutNotLoggedIn() throws Exception { var result = resource.doLogout(); // Check the response - assertEquals(0, result.roles().length); + assertThat(result.roles()).isEmpty(); assertEquals("", result.errorMessage()); } }