Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuanww committed Feb 22, 2025
1 parent 697c593 commit f6c630d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import org.junit.jupiter.api.Test;

public class ReportAuthorDetailsTest {
private static final ReportAuthorDetails details1 = new ReportAuthorDetails(
List.of("[email protected]"),
"gitHostId",
"Display Name",
"Git Author"
);

@Test
public void constructor_withValidInputs_success() {
List<String> emails = List.of("[email protected]", "[email protected]");
Expand Down Expand Up @@ -36,13 +43,11 @@ public void constructor_nullGitHostId_throwsIllegalArgumentException() {

@Test
public void equals_sameObject_success() {
ReportAuthorDetails details1 = new ReportAuthorDetails(
List.of("[email protected]"),
"gitHostId",
"Display Name",
"Git Author"
);
Assertions.assertEquals(details1, details1);
}

@Test
public void equals_equivalentObject_success() {
ReportAuthorDetails details2 = new ReportAuthorDetails(
List.of("[email protected]"),
"gitHostId",
Expand All @@ -55,20 +60,13 @@ public void equals_sameObject_success() {

@Test
public void equals_differentObject_failure() {
ReportAuthorDetails details1 = new ReportAuthorDetails(
List.of("[email protected]"),
"gitHostId",
"Display Name",
"Git Author"
);

ReportAuthorDetails details2 = new ReportAuthorDetails(
List.of("test@example.com"),
List.of("test1@example.com"),
"gitHostId",
"Display Name",
"Git Author"
);

Assertions.assertNotEquals(details1, details2);
Assertions.assertFalse(details1.equals(details2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
import org.junit.jupiter.api.Test;

public class ReportBranchDataTest {
private static final ReportBranchData data1 = new ReportBranchData(
"main",
"Test blurb",
null,
List.of("*.log"),
List.of("bot"),
2000000L
);

@Test
public void constructor_withValidInputs_success() {
String branch = "main";
Expand Down Expand Up @@ -40,15 +49,11 @@ public void constructor_withNullInputs_shouldUseDefaultValues() {

@Test
public void equals_sameObject_success() {
ReportBranchData data1 = new ReportBranchData(
"main",
"Test blurb",
null,
List.of("*.log"),
List.of("bot"),
2000000L
);
Assertions.assertEquals(data1, data1);
}

@Test
public void equals_equivalentObject_success() {
ReportBranchData data2 = new ReportBranchData(
"main",
"Test blurb",
Expand All @@ -63,15 +68,6 @@ public void equals_sameObject_success() {

@Test
public void equals_differentObject_failure() {
ReportBranchData data1 = new ReportBranchData(
"main",
"Test blurb",
null,
List.of("*.log"),
List.of("bot"),
2000000L
);

ReportBranchData data2 = new ReportBranchData(
"master",
"Test blurb",
Expand All @@ -81,6 +77,6 @@ public void equals_differentObject_failure() {
2000000L
);

Assertions.assertNotEquals(data1, data2);
Assertions.assertFalse(data1.equals(data2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public void equals_withSameObject_success() {

@Test
public void equals_withDifferentObject_failure() {
Assertions.assertNotEquals(new ReportConfiguration(), expectedReportConfig);
Assertions.assertFalse(expectedReportConfig.equals(new ReportConfiguration(null, null)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
import reposense.model.FileType;

public class ReportGroupNameAndGlobsTest {
private static final ReportGroupNameAndGlobs reportGroupNameAndGlobs1 = new ReportGroupNameAndGlobs("My Group",
List.of("code"));

@Test
public void constructor_withValidInputs_success() {
ReportGroupNameAndGlobs reportGroupNameAndGlobs = new ReportGroupNameAndGlobs("My Group", List.of("code"));
Assertions.assertNotNull(reportGroupNameAndGlobs);
Assertions.assertNotNull(reportGroupNameAndGlobs1);
Assertions.assertEquals("My Group", reportGroupNameAndGlobs1.getGroupName());
Assertions.assertEquals(List.of("code"), reportGroupNameAndGlobs1.getGlobs());
}

@Test
Expand All @@ -32,21 +36,17 @@ public void constructor_nullGroupNameAndNullGlobs_throwsIllegalArgumentException

@Test
public void toFileType_success() {
ReportGroupNameAndGlobs reportGroupNameAndGlobs = new ReportGroupNameAndGlobs("My Group", List.of("code"));
Assertions.assertEquals(new FileType("My Group", List.of("code")), reportGroupNameAndGlobs.toFileType());
Assertions.assertEquals(new FileType("My Group", List.of("code")), reportGroupNameAndGlobs1.toFileType());
}

@Test
public void equals_sameObject_success() {
ReportGroupNameAndGlobs reportGroupNameAndGlobs1 = new ReportGroupNameAndGlobs("My Group", List.of("code"));
ReportGroupNameAndGlobs reportGroupNameAndGlobs2 = new ReportGroupNameAndGlobs("My Group", List.of("code"));
Assertions.assertEquals(reportGroupNameAndGlobs1, reportGroupNameAndGlobs2);
Assertions.assertEquals(reportGroupNameAndGlobs1, reportGroupNameAndGlobs1);
}

@Test
public void equals_differentObject_failure() {
ReportGroupNameAndGlobs reportGroupNameAndGlobs1 = new ReportGroupNameAndGlobs("My Group", List.of("code"));
ReportGroupNameAndGlobs reportGroupNameAndGlobs2 = new ReportGroupNameAndGlobs("My Group", List.of("test"));
Assertions.assertNotEquals(reportGroupNameAndGlobs1, reportGroupNameAndGlobs2);
Assertions.assertFalse(reportGroupNameAndGlobs1.equals(reportGroupNameAndGlobs2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import reposense.parser.exceptions.InvalidLocationException;

public class ReportRepoConfigurationTest {
private static final List<ReportGroupNameAndGlobs> groups = List.of(
new ReportGroupNameAndGlobs("group1", List.of("glob1", "glob2")),
new ReportGroupNameAndGlobs("group2", List.of("glob3", "glob4"))
);

@Test
void constructor_nullRepo_throwsIllegalArgumentException() {
Assertions.assertThrows(IllegalArgumentException.class, () ->
Expand Down Expand Up @@ -62,10 +67,6 @@ void getFullyQualifiedRepoNamesWithBlurbs_invalidUrl_throwsIllegalArgumentExcept

@Test
void getGroupConfiguration_validGroups_returnsCorrectMapping() throws InvalidLocationException {
List<ReportGroupNameAndGlobs> groups = List.of(
new ReportGroupNameAndGlobs("group1", List.of("glob1", "glob2")),
new ReportGroupNameAndGlobs("group2", List.of("glob3", "glob4"))
);
ReportRepoConfiguration config = new ReportRepoConfiguration(
"https://github.com/test/repo.git", groups, null);

Expand All @@ -80,10 +81,6 @@ void getGroupConfiguration_validGroups_returnsCorrectMapping() throws InvalidLoc

@Test
void equals_sameObject_success() {
List<ReportGroupNameAndGlobs> groups = List.of(
new ReportGroupNameAndGlobs("group1", List.of("glob1", "glob2")),
new ReportGroupNameAndGlobs("group2", List.of("glob3", "glob4"))
);
ReportRepoConfiguration config = new ReportRepoConfiguration(
"https://github.com/test/repo.git", groups, null);

Expand All @@ -92,15 +89,11 @@ void equals_sameObject_success() {

@Test
void equals_differentObject_failure() {
List<ReportGroupNameAndGlobs> groups = List.of(
new ReportGroupNameAndGlobs("group1", List.of("glob1", "glob2")),
new ReportGroupNameAndGlobs("group2", List.of("glob3", "glob4"))
);
ReportRepoConfiguration config1 = new ReportRepoConfiguration(
"https://github.com/dev/repo.git", groups, null);
ReportRepoConfiguration config2 = new ReportRepoConfiguration(
"https://github.com/test/repo.git", groups, null);

Assertions.assertNotEquals(config1, config2);
Assertions.assertFalse(config1.equals(config2));
}
}

0 comments on commit f6c630d

Please sign in to comment.