Skip to content

Commit

Permalink
Rename alignmentObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed Jun 13, 2024
1 parent db10d5f commit 5b6a687
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/java/ch/puzzle/okr/dto/AlignmentDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import java.util.List;

public record AlignmentDto(Long teamId, String teamName, List<AlignmentObjectDto> alignmentObjectDtos) {
public record AlignmentDto(Long teamId, String teamName, List<AlignmentObjectDto> alignmentObjects) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ void getAlignmentPossibilities() throws Exception {
mvc.perform(get(URL_BASE_OBJECTIVE + "/alignmentPossibilities/5").contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$[0].teamId", Is.is(1)))
.andExpect(jsonPath("$[0].teamName", Is.is(TEAM_PUZZLE)))
.andExpect(jsonPath("$[0].alignmentObjectDtos[0].objectId", Is.is(3)))
.andExpect(jsonPath("$[0].alignmentObjectDtos[0].objectTitle", Is.is("KR Title 1")))
.andExpect(jsonPath("$[0].alignmentObjectDtos[0].objectType", Is.is("keyResult")))
.andExpect(jsonPath("$[0].alignmentObjectDtos[1].objectId", Is.is(1)))
.andExpect(jsonPath("$[0].alignmentObjectDtos[1].objectTitle", Is.is("Objective Title 1")))
.andExpect(jsonPath("$[0].alignmentObjectDtos[1].objectType", Is.is(OBJECTIVE)));
.andExpect(jsonPath("$[0].alignmentObjects[0].objectId", Is.is(3)))
.andExpect(jsonPath("$[0].alignmentObjects[0].objectTitle", Is.is("KR Title 1")))
.andExpect(jsonPath("$[0].alignmentObjects[0].objectType", Is.is("keyResult")))
.andExpect(jsonPath("$[0].alignmentObjects[1].objectId", Is.is(1)))
.andExpect(jsonPath("$[0].alignmentObjects[1].objectTitle", Is.is("Objective Title 1")))
.andExpect(jsonPath("$[0].alignmentObjects[1].objectType", Is.is(OBJECTIVE)));

verify(objectiveAuthorizationService, times(1)).getAlignmentPossibilities(5L);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ void getAlignmentPossibilitiesShouldReturnListWhenAuthorized() {
// assert
assertEquals(TEAM_PUZZLE, alignmentPossibilities.get(0).teamName());
assertEquals(1, alignmentPossibilities.get(0).teamId());
assertEquals(3, alignmentPossibilities.get(0).alignmentObjectDtos().get(0).objectId());
assertEquals("KR Title 1", alignmentPossibilities.get(0).alignmentObjectDtos().get(0).objectTitle());
assertEquals("keyResult", alignmentPossibilities.get(0).alignmentObjectDtos().get(0).objectType());
assertEquals(1, alignmentPossibilities.get(0).alignmentObjectDtos().get(1).objectId());
assertEquals("objective", alignmentPossibilities.get(0).alignmentObjectDtos().get(1).objectType());
assertEquals(3, alignmentPossibilities.get(0).alignmentObjects().get(0).objectId());
assertEquals("KR Title 1", alignmentPossibilities.get(0).alignmentObjects().get(0).objectTitle());
assertEquals("keyResult", alignmentPossibilities.get(0).alignmentObjects().get(0).objectType());
assertEquals(1, alignmentPossibilities.get(0).alignmentObjects().get(1).objectId());
assertEquals("objective", alignmentPossibilities.get(0).alignmentObjects().get(1).objectType());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,13 @@ void shouldReturnAlignmentPossibilitiesOnlyObjectives() {
verify(objectivePersistenceService, times(1)).findObjectiveByQuarterId(5L);
verify(keyResultBusinessService, times(1)).getAllKeyResultsByObjective(1L);
verify(keyResultBusinessService, times(1)).getAllKeyResultsByObjective(2L);
assertEquals(2, alignmentsDtos.get(0).alignmentObjectDtos().size());
assertEquals(1, alignmentsDtos.get(0).alignmentObjectDtos().get(0).objectId());
assertEquals(FULL_OBJECTIVE_1, alignmentsDtos.get(0).alignmentObjectDtos().get(0).objectTitle());
assertEquals(OBJECTIVE, alignmentsDtos.get(0).alignmentObjectDtos().get(0).objectType());
assertEquals(2, alignmentsDtos.get(0).alignmentObjectDtos().get(1).objectId());
assertEquals(FULL_OBJECTIVE_2, alignmentsDtos.get(0).alignmentObjectDtos().get(1).objectTitle());
assertEquals(OBJECTIVE, alignmentsDtos.get(0).alignmentObjectDtos().get(1).objectType());
assertEquals(2, alignmentsDtos.get(0).alignmentObjects().size());
assertEquals(1, alignmentsDtos.get(0).alignmentObjects().get(0).objectId());
assertEquals(FULL_OBJECTIVE_1, alignmentsDtos.get(0).alignmentObjects().get(0).objectTitle());
assertEquals(OBJECTIVE, alignmentsDtos.get(0).alignmentObjects().get(0).objectType());
assertEquals(2, alignmentsDtos.get(0).alignmentObjects().get(1).objectId());
assertEquals(FULL_OBJECTIVE_2, alignmentsDtos.get(0).alignmentObjects().get(1).objectTitle());
assertEquals(OBJECTIVE, alignmentsDtos.get(0).alignmentObjects().get(1).objectType());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<mat-autocomplete requireSelection #auto="matAutocomplete" [displayWith]="displayWith">
@for (group of filteredAlignmentOptions$ | async; track group) {
<mat-optgroup [label]="group.teamName" style="font-weight: bold">
@for (alignmentObject of group.alignmentObjectDtos; track alignmentObject) {
@for (alignmentObject of group.alignmentObjects; track alignmentObject) {
<mat-option [value]="alignmentObject">{{ alignmentObject.objectTitle }}</mat-option>
}
</mat-optgroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ describe('ObjectiveDialogComponent', () => {
let modifiedAlignmentPossibility: AlignmentPossibility = {
teamId: 1,
teamName: 'Puzzle ITC',
alignmentObjectDtos: [alignmentObject3],
alignmentObjects: [alignmentObject3],
};
expect(component.filteredAlignmentOptions$.getValue()).toEqual([modifiedAlignmentPossibility]);

Expand All @@ -563,7 +563,7 @@ describe('ObjectiveDialogComponent', () => {
modifiedAlignmentPossibility = {
teamId: 1,
teamName: 'Puzzle ITC',
alignmentObjectDtos: [alignmentObject2, alignmentObject3],
alignmentObjects: [alignmentObject2, alignmentObject3],
};
expect(component.filteredAlignmentOptions$.getValue()).toEqual([modifiedAlignmentPossibility]);

Expand All @@ -575,12 +575,12 @@ describe('ObjectiveDialogComponent', () => {
{
teamId: 1,
teamName: 'Puzzle ITC',
alignmentObjectDtos: [alignmentObject3],
alignmentObjects: [alignmentObject3],
},
{
teamId: 2,
teamName: 'We are cube',
alignmentObjectDtos: [alignmentObject1],
alignmentObjects: [alignmentObject1],
},
];
expect(component.filteredAlignmentOptions$.getValue()).toEqual(modifiedAlignmentPossibilities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class ObjectiveFormComponent implements OnInit {
objectType: string,
): AlignmentPossibilityObject | null {
for (let possibility of alignmentPossibilities) {
let foundObject: AlignmentPossibilityObject | undefined = possibility.alignmentObjectDtos.find(
let foundObject: AlignmentPossibilityObject | undefined = possibility.alignmentObjects.find(
(alignmentObject: AlignmentPossibilityObject) =>
alignmentObject.objectId === objectId && alignmentObject.objectType === objectType,
);
Expand Down Expand Up @@ -329,7 +329,7 @@ export class ObjectiveFormComponent implements OnInit {

getMatchingAlignmentPossibilityObjectsByInputFilter(filterValue: string): AlignmentPossibilityObject[] {
return this.alignmentPossibilities.flatMap((alignmentPossibility: AlignmentPossibility) =>
alignmentPossibility.alignmentObjectDtos.filter((alignmentPossibilityObject: AlignmentPossibilityObject) =>
alignmentPossibility.alignmentObjects.filter((alignmentPossibilityObject: AlignmentPossibilityObject) =>
alignmentPossibilityObject.objectTitle.toLowerCase().includes(filterValue),
),
);
Expand All @@ -338,7 +338,7 @@ export class ObjectiveFormComponent implements OnInit {
getAlignmentPossibilityFromAlignmentObject(filteredObjects: AlignmentPossibilityObject[]): AlignmentPossibility[] {
return this.alignmentPossibilities.filter((possibility: AlignmentPossibility) =>
filteredObjects.some((alignmentPossibilityObject: AlignmentPossibilityObject) =>
possibility.alignmentObjectDtos.includes(alignmentPossibilityObject),
possibility.alignmentObjects.includes(alignmentPossibilityObject),
),
);
}
Expand All @@ -349,9 +349,8 @@ export class ObjectiveFormComponent implements OnInit {
): AlignmentPossibility[] {
return matchingPossibilities.map((possibility: AlignmentPossibility) => ({
...possibility,
alignmentObjectDtos: possibility.alignmentObjectDtos.filter(
(alignmentPossibilityObject: AlignmentPossibilityObject) =>
filteredObjects.includes(alignmentPossibilityObject),
alignmentObjects: possibility.alignmentObjects.filter((alignmentPossibilityObject: AlignmentPossibilityObject) =>
filteredObjects.includes(alignmentPossibilityObject),
),
}));
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/shared/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,11 @@ export const alignmentObject3: AlignmentPossibilityObject = {
export const alignmentPossibility1: AlignmentPossibility = {
teamId: 1,
teamName: 'Puzzle ITC',
alignmentObjectDtos: [alignmentObject2, alignmentObject3],
alignmentObjects: [alignmentObject2, alignmentObject3],
};

export const alignmentPossibility2: AlignmentPossibility = {
teamId: 2,
teamName: 'We are cube',
alignmentObjectDtos: [alignmentObject1],
alignmentObjects: [alignmentObject1],
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { AlignmentPossibilityObject } from './AlignmentPossibilityObject';
export interface AlignmentPossibility {
teamId: number;
teamName: string;
alignmentObjectDtos: AlignmentPossibilityObject[];
alignmentObjects: AlignmentPossibilityObject[];
}

0 comments on commit 5b6a687

Please sign in to comment.