Skip to content

Commit

Permalink
fix backend tests by resolving import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 19, 2024
1 parent 77d3621 commit 12ec573
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.puzzle.okr.dto.alignment.AlignmentLists;
import ch.puzzle.okr.dto.alignment.AlignmentObjectDto;
import ch.puzzle.okr.service.business.AlignmentBusinessService;
import ch.puzzle.okr.test.TestConstants;
import org.hamcrest.Matchers;
import org.hamcrest.core.Is;
import org.junit.jupiter.api.Test;
Expand All @@ -20,7 +21,7 @@

import java.util.List;

import static ch.puzzle.okr.TestConstants.TEAM_PUZZLE;
import static ch.puzzle.okr.test.TestConstants.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ch.puzzle.okr.models.*;
import ch.puzzle.okr.service.authorization.AuthorizationService;
import ch.puzzle.okr.service.authorization.ObjectiveAuthorizationService;
import ch.puzzle.okr.test.TestConstants;
import org.hamcrest.core.Is;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -29,12 +30,12 @@
import java.time.LocalDateTime;
import java.util.List;

import static ch.puzzle.okr.test.TestConstants.TEAM_PUZZLE;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static ch.puzzle.okr.TestConstants.*;

@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void toObjectiveShouldMapDtoToObjective() {
STATE, //
CREATE_DATE_TIME, //
MODIFIED_DATE_TIME, //
IS_WRITEABLE //
);
IS_WRITEABLE, //
null);

// mock (LocalDateTime.now()) + act + assert
try (MockedStatic<LocalDateTime> mockedStatic = Mockito.mockStatic(LocalDateTime.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static ch.puzzle.okr.TestConstants.*;

@ExtendWith(MockitoExtension.class)
class OverviewMapperTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import java.util.List;

import static ch.puzzle.okr.test.TestConstants.TEAM_PUZZLE;
import static ch.puzzle.okr.test.TestHelper.defaultAuthorizationUser;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static ch.puzzle.okr.TestConstants.*;

@ExtendWith(MockitoExtension.class)
class ObjectiveAuthorizationServiceTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.puzzle.okr.service.business;

import ch.puzzle.okr.TestHelper;
import ch.puzzle.okr.dto.ErrorDto;
import ch.puzzle.okr.dto.alignment.AlignmentLists;
import ch.puzzle.okr.dto.alignment.AlignedEntityDto;
Expand All @@ -18,6 +17,7 @@
import ch.puzzle.okr.service.persistence.KeyResultPersistenceService;
import ch.puzzle.okr.service.persistence.ObjectivePersistenceService;
import ch.puzzle.okr.service.validation.AlignmentValidationService;
import ch.puzzle.okr.test.TestHelper;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ch.puzzle.okr.models.keyresult.KeyResultOrdinal;
import ch.puzzle.okr.service.persistence.ObjectivePersistenceService;
import ch.puzzle.okr.service.validation.ObjectiveValidationService;
import ch.puzzle.okr.test.TestConstants;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -26,14 +27,14 @@
import java.time.LocalDateTime;
import java.util.List;

import static ch.puzzle.okr.test.TestConstants.TEAM_PUZZLE;
import static ch.puzzle.okr.test.TestHelper.defaultAuthorizationUser;
import static ch.puzzle.okr.models.State.DRAFT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static ch.puzzle.okr.TestConstants.*;

@ExtendWith(MockitoExtension.class)
class ObjectiveBusinessServiceTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.puzzle.okr.service.validation;

import ch.puzzle.okr.TestHelper;
import ch.puzzle.okr.dto.ErrorDto;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Objective;
Expand All @@ -11,6 +10,7 @@
import ch.puzzle.okr.models.keyresult.KeyResultMetric;
import ch.puzzle.okr.service.persistence.AlignmentPersistenceService;
import ch.puzzle.okr.service.persistence.TeamPersistenceService;
import ch.puzzle.okr.test.TestHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -23,11 +23,12 @@
import java.util.List;

import static ch.puzzle.okr.models.State.DRAFT;
import static ch.puzzle.okr.test.TestConstants.TEAM_PUZZLE;
import static ch.puzzle.okr.test.TestHelper.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static ch.puzzle.okr.TestConstants.*;

@ExtendWith(MockitoExtension.class)
class AlignmentValidationServiceTest {
Expand Down Expand Up @@ -148,7 +149,7 @@ void validateOnCreateShouldThrowExceptionWhenAlignedObjectiveIsNull() {
// assert
assertEquals(BAD_REQUEST, exception.getStatusCode());
assertThat(expectedErrors).hasSameElementsAs(exception.getErrors());
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
assertTrue(getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@Test
Expand Down
19 changes: 0 additions & 19 deletions frontend/src/app/shared/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,12 @@ import { KeyResultMetric } from './types/model/KeyResultMetric';
import { Unit } from './types/enums/Unit';
import { Team } from './types/model/Team';
import { Action } from './types/model/Action';
import { OrganisationState } from './types/enums/OrganisationState';
import { Organisation } from './types/model/Organisation';
import { Dashboard } from './types/model/Dashboard';
import { AlignmentObject } from './types/model/AlignmentObject';
import { AlignmentConnection } from './types/model/AlignmentConnection';
import { AlignmentLists } from './types/model/AlignmentLists';
import { AlignmentPossibilityObject } from './types/model/AlignmentPossibilityObject';
import { AlignmentPossibility } from './types/model/AlignmentPossibility';

export const organisationActive = {
id: 1,
version: 1,
orgName: 'org_bbt',
teams: [],
state: OrganisationState.ACTIVE,
} as Organisation;

export const organisationInActive = {
id: 1,
version: 1,
orgName: 'org_mobility',
teams: [],
state: OrganisationState.INACTIVE,
} as Organisation;

export const teamFormObject = {
name: 'newTeamName',
};
Expand Down

0 comments on commit 12ec573

Please sign in to comment.