From c8375ae85676d93fb3314912d19f376325f60bc8 Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Tue, 7 Jan 2025 10:24:07 +0100 Subject: [PATCH] apply backend formatter --- backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java | 1 - .../src/main/java/ch/puzzle/okr/mapper/UserMapper.java | 1 - .../ch/puzzle/okr/multitenancy/HibernateContext.java | 3 +-- .../ch/puzzle/okr/security/helper/JwtStatusLogger.java | 9 +++------ .../puzzle/okr/service/business/TeamBusinessService.java | 7 ++++--- .../service/persistence/KeyResultPersistenceService.java | 2 -- .../ch/puzzle/okr/util/quarter/generate/Quarters.java | 3 ++- .../ch/puzzle/okr/multitenancy/HibernateContextTest.java | 8 ++++---- 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java b/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java index 6c8c302837..87eef24724 100644 --- a/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java +++ b/backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java @@ -1,7 +1,6 @@ package ch.puzzle.okr.dto; import ch.puzzle.okr.ErrorKey; - import java.io.Serializable; import java.util.List; diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java index d5093854f4..3a59783879 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java @@ -5,7 +5,6 @@ import ch.puzzle.okr.dto.UserTeamDto; import ch.puzzle.okr.models.User; import java.util.List; -import java.util.stream.Collectors; import org.springframework.stereotype.Component; @Component diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java index 6f01087221..7760fec132 100644 --- a/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java +++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/HibernateContext.java @@ -1,9 +1,8 @@ package ch.puzzle.okr.multitenancy; import ch.puzzle.okr.exception.HibernateContextException; -import org.springframework.core.env.ConfigurableEnvironment; - import java.util.Properties; +import org.springframework.core.env.ConfigurableEnvironment; public class HibernateContext { public static final String HIBERNATE_CONNECTION_URL = "hibernate.connection.url"; diff --git a/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java b/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java index 23da0771e1..018ff30df1 100644 --- a/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java +++ b/backend/src/main/java/ch/puzzle/okr/security/helper/JwtStatusLogger.java @@ -17,17 +17,14 @@ public static void logStatus(String claim, Object context, String result) { public static void logStatus(String claim, Object context, boolean isOk) { if (isOk) { - logger - .atInfo().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(isOk)); + logger.atInfo().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(isOk)); } else { - logger - .atWarn().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(isOk)); + logger.atWarn().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(isOk)); } } public static void logStatus(String claim, Object context, ParseException e) { - logger - .atWarn().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(false), e); + logger.atWarn().log(LOG_MESSAGE, claim, context.getClass().getSimpleName(), statusToSymbol(false), e); } private static String statusToSymbol(boolean isOk) { diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java index c32228184e..48a72dec84 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/business/TeamBusinessService.java @@ -138,9 +138,10 @@ public void removeUserFromTeam(long teamId, long userId) { } private void checkTeamHasAtLeastOneAdmin(Team team, User user) { - boolean hasAdmin = team.getUserTeamList().stream() - .anyMatch(ut -> ut.isTeamAdmin() && !Objects.equals(ut.getUser().getId(), user.getId())) - ; + boolean hasAdmin = team + .getUserTeamList() + .stream() + .anyMatch(ut -> ut.isTeamAdmin() && !Objects.equals(ut.getUser().getId(), user.getId())); if (!hasAdmin) { throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST, ErrorKey.TRIED_TO_DELETE_LAST_ADMIN); } diff --git a/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java b/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java index d0e01d16b4..fad7a82806 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/persistence/KeyResultPersistenceService.java @@ -6,8 +6,6 @@ import ch.puzzle.okr.repository.KeyResultRepository; import jakarta.transaction.Transactional; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @Service diff --git a/backend/src/main/java/ch/puzzle/okr/util/quarter/generate/Quarters.java b/backend/src/main/java/ch/puzzle/okr/util/quarter/generate/Quarters.java index ba9866f531..a722d9c343 100644 --- a/backend/src/main/java/ch/puzzle/okr/util/quarter/generate/Quarters.java +++ b/backend/src/main/java/ch/puzzle/okr/util/quarter/generate/Quarters.java @@ -48,7 +48,8 @@ private LocalDate toDate(int year, String monthDay) { return LocalDate.parse(year + "-" + monthDay); } - // Runtime exception is okay here, because the class is only used for testing purposes + // Runtime exception is okay here, because the class is only used for testing + // purposes @SuppressWarnings("java:S112") public QuarterData currentQuarter(LocalDate date) { String label = new QuarterLabel(date).label(); diff --git a/backend/src/test/java/ch/puzzle/okr/multitenancy/HibernateContextTest.java b/backend/src/test/java/ch/puzzle/okr/multitenancy/HibernateContextTest.java index 1ac270fc43..d3a2ddd5eb 100644 --- a/backend/src/test/java/ch/puzzle/okr/multitenancy/HibernateContextTest.java +++ b/backend/src/test/java/ch/puzzle/okr/multitenancy/HibernateContextTest.java @@ -5,9 +5,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import ch.puzzle.okr.exception.HibernateContextException; import java.util.Properties; import java.util.stream.Stream; -import ch.puzzle.okr.exception.HibernateContextException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -31,7 +31,7 @@ void setHibernateConfigShouldThrowExceptionIfDbConfigIsNull() { // act + assert HibernateContextException exception = assertThrows(HibernateContextException.class, - () -> setHibernateConfig(dbConfig)); + () -> setHibernateConfig(dbConfig)); assertEquals("Invalid hibernate configuration null", exception.getMessage()); } @@ -45,7 +45,7 @@ void setHibernateConfigShouldThrowExceptionIfDbConfigHasNullOrEmptyValues(String // act + assert HibernateContextException exception = assertThrows(HibernateContextException.class, - () -> setHibernateConfig(dbConfig)); + () -> setHibernateConfig(dbConfig)); assertTrue(exception.getMessage().startsWith("Invalid hibernate configuration")); } @@ -90,7 +90,7 @@ void getHibernateConfigShouldThrowExceptionIfSetHibernateConfigIsNotCalledBefore // act + assert HibernateContextException exception = assertThrows(HibernateContextException.class, - HibernateContext::getHibernateConfig); + HibernateContext::getHibernateConfig); assertEquals("No cached hibernate configuration found", exception.getMessage()); }