Java_teammate_pair_testing
Build the project with Maven Tool
mvn -B package --file pom.xml
Clean, install, and generate report
mvn clean install site -P test
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Java CI with Maven | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,5 @@ | |
<version>7.9.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package time; | ||
|
||
public class MonthDaysCalculator { | ||
|
||
private MonthDaysCalculator() { | ||
} | ||
|
||
public static String[] getMonthsByDays(int days) { | ||
return isValidDay(days) | ||
? getMonthNames(days) | ||
: new String[0]; | ||
} | ||
|
||
private static String[] getMonthNames(int days) { | ||
if (days == 28 || days == 29) { | ||
return new String[]{MonthType.FEBRUARY.getName()}; | ||
} | ||
int index = 0; | ||
String[] monthNames = new String[getSize(days)]; | ||
for (MonthType month : MonthType.values()) { | ||
if (month.getDays() == days) { | ||
monthNames[index++] = (month.getName()); | ||
} | ||
} | ||
return monthNames; | ||
} | ||
|
||
private static int getSize(int days) { | ||
return switch (days) { | ||
case 31 -> 7; | ||
case 30 -> 4; | ||
default -> 1; | ||
}; | ||
} | ||
|
||
public static boolean isValidDay(int days) { | ||
return !(days < 1 || days > 31); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package time; | ||
|
||
import java.time.LocalDate; | ||
|
||
public enum MonthType { | ||
JANUARY("January"), | ||
FEBRUARY("February"), | ||
MARCH("March"), | ||
APRIL("April"), | ||
MAY("May"), | ||
JUNE("June"), | ||
JULY("July"), | ||
AUGUST("August"), | ||
SEPTEMBER("September"), | ||
OCTOBER("October"), | ||
NOVEMBER("November"), | ||
DECEMBER("December"); | ||
|
||
private final String name; | ||
|
||
MonthType(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getDays() { | ||
return getDaysBy(); | ||
} | ||
|
||
public int getDaysBy() { | ||
return switch (this) { | ||
case FEBRUARY -> (isLeap() ? 29 : 28); | ||
case APRIL, JUNE, SEPTEMBER, NOVEMBER -> 30; | ||
case JANUARY, MARCH, MAY, JULY, AUGUST, OCTOBER, DECEMBER -> 31; | ||
}; | ||
} | ||
|
||
private static boolean isLeap() { | ||
int year = LocalDate.now().getYear(); | ||
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package time; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class MonthDaysCalculatorTest { | ||
|
||
@Test(dataProvider = "validDays", dataProviderClass = MonthProvider.class) | ||
public void testName(int days, String[] expected) { | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package time; | ||
|
||
import org.testng.annotations.DataProvider; | ||
|
||
public class MonthProvider { | ||
@DataProvider(name = "validDays") | ||
public Object[][] daysProvider() { | ||
return new Object[][]{}; | ||
} | ||
} |