-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
236 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
core/src/main/java/de/jplag/reporting/reportobject/model/ComparisonReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
package de.jplag.reporting.reportobject.model; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* ReportViewer DTO for the comparison of two submissions. | ||
* @param firstSubmissionId id of the first submission | ||
* @param secondSubmissionId id of the second submission | ||
* @param similarity average similarity. between 0.0 and 1.0. | ||
* @param similarities map of metric names and corresponding similarities. between 0.0 and 1.0. | ||
* @param matches the list of matches found in the comparison of the two submissions | ||
*/ | ||
public record ComparisonReport(@JsonProperty("id1") String firstSubmissionId, @JsonProperty("id2") String secondSubmissionId, | ||
@JsonProperty("similarity") double similarity, @JsonProperty("matches") List<Match> matches) { | ||
@JsonProperty("similarities") Map<String, Double> similarities, @JsonProperty("matches") List<Match> matches) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
report-viewer/tests/unit/model/factories/ComparisonFactory.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { vi, it, beforeAll, describe, expect } from 'vitest' | ||
import validNew from './ValidNewComparison.json' | ||
import validOld from './ValidOldComparison.json' | ||
import { ComparisonFactory } from '@/model/factories/ComparisonFactory' | ||
import store from '@/stores/store' | ||
import MetricType from '@/model/MetricType' | ||
|
||
const store = { | ||
state: { | ||
localModeUsed: false, | ||
zipModeUsed: true, | ||
singleModeUsed: false, | ||
files: {} | ||
}, | ||
getComparisonFileName: (id1: string, id2: string) => { | ||
return `${id1}-${id2}.json` | ||
}, | ||
filesOfSubmission: (name: string) => { | ||
return [ | ||
{ | ||
name: `${name}/Structure.java`, | ||
value: '' | ||
}, | ||
{ | ||
name: `${name}/Submission.java`, | ||
value: '' | ||
} | ||
] | ||
} | ||
} | ||
|
||
describe('Test JSON to Comparison', () => { | ||
beforeAll(() => { | ||
vi.mock('@/stores/store', () => ({ | ||
default: vi.fn(() => { | ||
return store | ||
}) | ||
})) | ||
}) | ||
|
||
it('Post 5.0', () => { | ||
store.state.files['root1-root2.json'] = JSON.stringify(validNew) | ||
|
||
const result = ComparisonFactory.getComparison('root1', 'root2') | ||
|
||
expect(result).toBeDefined() | ||
expect(result.firstSubmissionId).toBe('root1') | ||
expect(result.secondSubmissionId).toBe('root2') | ||
expect(result.similarities[MetricType.AVERAGE]).toBe(0.6900452488687783) | ||
expect(result.similarities[MetricType.MAXIMUM]).toBe(0.9936000000000001) | ||
expect(result.filesOfFirstSubmission).toBeDefined() | ||
expect(result.filesOfSecondSubmission).toBeDefined() | ||
expect(result.allMatches.length).toBe(4) | ||
expect(result.matchesInFirstSubmission.size).toBe(2) | ||
expect(result.matchesInSecondSubmissions.size).toBe(2) | ||
}) | ||
|
||
it('Pre 5.0', () => { | ||
store.state.files['root1-root2.json'] = JSON.stringify(validOld) | ||
|
||
const result = ComparisonFactory.getComparison('root1', 'root2') | ||
|
||
expect(result).toBeDefined() | ||
expect(result.firstSubmissionId).toBe('root1') | ||
expect(result.secondSubmissionId).toBe('root2') | ||
expect(result.similarities[MetricType.AVERAGE]).toBe(0.6900452488687783) | ||
expect(result.similarities[MetricType.MAXIMUM]).toBe(Number.NaN) | ||
expect(result.filesOfFirstSubmission).toBeDefined() | ||
expect(result.filesOfSecondSubmission).toBeDefined() | ||
expect(result.allMatches.length).toBe(4) | ||
expect(result.matchesInFirstSubmission.size).toBe(2) | ||
expect(result.matchesInSecondSubmissions.size).toBe(2) | ||
}) | ||
}) |
Oops, something went wrong.