Skip to content

Commit

Permalink
apply backend formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jan 7, 2025
1 parent 8926ed7 commit cda0951
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion backend/src/main/java/ch/puzzle/okr/dto/ErrorDto.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.puzzle.okr.dto;

import ch.puzzle.okr.ErrorKey;

import java.io.Serializable;
import java.util.List;

Expand Down
1 change: 0 additions & 1 deletion backend/src/main/java/ch/puzzle/okr/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +31,7 @@ void setHibernateConfigShouldThrowExceptionIfDbConfigIsNull() {

// act + assert
HibernateContextException exception = assertThrows(HibernateContextException.class,
() -> setHibernateConfig(dbConfig));
() -> setHibernateConfig(dbConfig));
assertEquals("Invalid hibernate configuration null", exception.getMessage());
}

Expand All @@ -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"));
}

Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit cda0951

Please sign in to comment.