-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add missing unit tests for
dashboard
classes (#253)
feat: Add missing unit tests for dashboard classes Signed-off-by: Oleg Kopysov <[email protected]>
- Loading branch information
Showing
7 changed files
with
195 additions
and
2 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
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
37 changes: 37 additions & 0 deletions
37
src/test/java/com/lpvs/entity/dashboard/DashBoardElementsTest.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. | ||
* | ||
* Use of this source code is governed by a MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package com.lpvs.entity.dashboard; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DashBoardElementsTest { | ||
|
||
private DashBoardElements dashBoardElements; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
Map<LocalDate, DashboardElementsByDate> dashboardElementsMap = new HashMap<>(); | ||
dashboardElementsMap.put(LocalDate.of(2023, 10, 1), new DashboardElementsByDate(LocalDate.of(2023, 10, 1), 10, 2, new HashMap<>())); | ||
dashboardElementsMap.put(LocalDate.of(2023, 10, 2), new DashboardElementsByDate(LocalDate.of(2023, 10, 2), 15, 5, new HashMap<>())); | ||
dashBoardElements = new DashBoardElements(dashboardElementsMap); | ||
} | ||
|
||
@Test | ||
public void testGetDashboardElementsMap() { | ||
Map<LocalDate, DashboardElementsByDate> expectedMap = new HashMap<>(); | ||
expectedMap.put(LocalDate.of(2023, 10, 1), new DashboardElementsByDate(LocalDate.of(2023, 10, 1), 10, 2, new HashMap<>())); | ||
expectedMap.put(LocalDate.of(2023, 10, 2), new DashboardElementsByDate(LocalDate.of(2023, 10, 2), 15, 5, new HashMap<>())); | ||
assertEquals(expectedMap, dashBoardElements.getDashboardElementsMap()); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/test/java/com/lpvs/entity/dashboard/DashboardElementsByDateTest.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. | ||
* | ||
* Use of this source code is governed by a MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package com.lpvs.entity.dashboard; | ||
|
||
import com.lpvs.entity.enums.Grade; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DashboardElementsByDateTest { | ||
|
||
private DashboardElementsByDate dashboardData; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
Map<Grade, Integer> riskGradeMap = new HashMap<>(); | ||
riskGradeMap.put(Grade.LOW, 5); | ||
riskGradeMap.put(Grade.MIDDLE, 3); | ||
dashboardData = new DashboardElementsByDate(LocalDate.of(2023, 10, 1), 10, 2, riskGradeMap); | ||
} | ||
|
||
@Test | ||
public void testGetDate() { | ||
assertEquals(LocalDate.of(2023, 10, 1), dashboardData.getDate()); | ||
} | ||
|
||
@Test | ||
public void testGetParticipantCount() { | ||
assertEquals(10, dashboardData.getParticipantCount()); | ||
} | ||
|
||
@Test | ||
public void testGetPullRequestCount() { | ||
assertEquals(2, dashboardData.getPullRequestCount()); | ||
} | ||
|
||
@Test | ||
public void testGetRiskGradeMap() { | ||
Map<Grade, Integer> expectedRiskGradeMap = new HashMap<>(); | ||
expectedRiskGradeMap.put(Grade.LOW, 5); | ||
expectedRiskGradeMap.put(Grade.MIDDLE, 3); | ||
|
||
assertEquals(expectedRiskGradeMap, dashboardData.getRiskGradeMap()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/test/java/com/lpvs/entity/dashboard/DashboardTest.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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. | ||
* | ||
* Use of this source code is governed by a MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package com.lpvs.entity.dashboard; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DashboardTest { | ||
|
||
private Dashboard dashboard; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
Map<String, Integer> licenseCountMap = new HashMap<>(); | ||
licenseCountMap.put("License1", 10); | ||
licenseCountMap.put("License2", 5); | ||
dashboard = new Dashboard("Test Dashboard", licenseCountMap, 100, 20, 30, 50, 10, null); | ||
} | ||
|
||
@Test | ||
public void testGetName() { | ||
assertEquals("Test Dashboard", dashboard.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetLicenseCountMap() { | ||
Map<String, Integer> expectedMap = new HashMap<>(); | ||
expectedMap.put("License1", 10); | ||
expectedMap.put("License2", 5); | ||
|
||
assertEquals(expectedMap, dashboard.getLicenseCountMap()); | ||
} | ||
|
||
@Test | ||
public void testTotalDetectionCount() { | ||
assertEquals(100, dashboard.getTotalDetectionCount()); | ||
} | ||
|
||
@Test | ||
public void testHighSimilarityCount() { | ||
assertEquals(20, dashboard.getHighSimilarityCount()); | ||
} | ||
|
||
@Test | ||
public void testTotalIssueCount() { | ||
assertEquals(30, dashboard.getTotalIssueCount()); | ||
} | ||
|
||
@Test | ||
public void testTotalParticipantsCount() { | ||
assertEquals(50, dashboard.getTotalParticipantsCount()); | ||
} | ||
|
||
@Test | ||
public void testTotalRepositoryCount() { | ||
assertEquals(10, dashboard.getTotalRepositoryCount()); | ||
} | ||
} |
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,31 @@ | ||
/** | ||
* Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. | ||
* | ||
* Use of this source code is governed by a MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package com.lpvs.entity.enums; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class GradeTest { | ||
|
||
@Test | ||
public void testGradeValues() { | ||
assertEquals(Grade.SERIOUS, Grade.valueOf("SERIOUS")); | ||
assertEquals(Grade.HIGH, Grade.valueOf("HIGH")); | ||
assertEquals(Grade.MIDDLE, Grade.valueOf("MIDDLE")); | ||
assertEquals(Grade.LOW, Grade.valueOf("LOW")); | ||
assertEquals(Grade.NONE, Grade.valueOf("NONE")); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
assertEquals("SERIOUS", Grade.SERIOUS.toString()); | ||
assertEquals("HIGH", Grade.HIGH.toString()); | ||
assertEquals("MIDDLE", Grade.MIDDLE.toString()); | ||
assertEquals("LOW", Grade.LOW.toString()); | ||
assertEquals("NONE", Grade.NONE.toString()); | ||
} | ||
} |