-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 4a8b770
Showing
5 changed files
with
288 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Java CI with Maven | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn -B -e verify |
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,47 @@ | ||
Thumbs.db* | ||
.DS_Store* | ||
HELP.md | ||
.gradle | ||
build/ | ||
target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Package Files ### | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
### Exclusions ### | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** |
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,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>ru.netology</groupId> | ||
<artifactId>Radio</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
<configuration> | ||
<failIfNoTests>true</failIfNoTests> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>0.8.5</version> | ||
<executions> | ||
<execution> | ||
<id>prepare-agent</id> | ||
<phase>initialize</phase> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>report</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<rules> | ||
<rule> | ||
<limits> | ||
<limit> | ||
<counter>BRANCH</counter> | ||
<value>COVEREDRATIO</value> | ||
<minimum>100%</minimum> | ||
</limit> | ||
</limits> | ||
</rule> | ||
</rules> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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,68 @@ | ||
package ru.netology.domain; | ||
|
||
public class Radio { | ||
public int currentStation; | ||
public int currentVolume; | ||
public int maxStation = 9; | ||
public int minStation = 0; | ||
public int maxVolume = 10; | ||
public int minVolume = 0; | ||
|
||
// 1) станции | ||
public int getCurrentStation() { | ||
return currentStation; | ||
} | ||
|
||
public void setCurrentStation(int currentStation) { | ||
if (currentStation <= maxStation && currentStation >= minStation) { | ||
this.currentStation = currentStation; | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
public void shiftNextStation() { | ||
if (currentStation == maxStation) { | ||
setCurrentStation(minStation); | ||
} else { | ||
currentStation++; | ||
} | ||
} | ||
|
||
public void shiftPrevStation() { | ||
if (currentStation == minStation) { | ||
setCurrentStation(maxStation); | ||
} else { | ||
currentStation--; | ||
} | ||
} | ||
|
||
// 2) звук | ||
public int getCurrentVolume() { | ||
return currentVolume; | ||
} | ||
|
||
public void setCurrentVolume(int currentVolume) { | ||
if (currentVolume <= maxVolume && currentVolume >= minVolume) { | ||
this.currentVolume = currentVolume; | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
public void increaseVolume() { | ||
if (currentVolume == maxVolume) { | ||
return; | ||
} else { | ||
currentVolume++; | ||
} | ||
} | ||
|
||
public void decreaseVolume() { | ||
if (currentVolume == minVolume) { | ||
return; | ||
} else { | ||
currentVolume--; | ||
} | ||
} | ||
} |
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,78 @@ | ||
package ru.netology.domain; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class RadioTest { | ||
Radio radioman = new Radio(); | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = {"equivalencePartitionInLimits,5,6", | ||
"equivalencePartitionOutLimitsBelow,-20,1", | ||
"equivalencePartitionOutLimitsAbove,20,1", | ||
"onMinLimit,0,1", | ||
"onMaxLimit,9,0", | ||
"boundaryOutBelowMinLimit,-1,1", | ||
"boundaryOutAboveMaxLimit,10,1", | ||
"boundaryInNearMinLimit,1,2", | ||
"boundaryInNearMaxLimit,8,9"}) | ||
void shouldShiftNextStation(String testcase, int currentStation, int expected) { | ||
radioman.setCurrentStation(currentStation); | ||
radioman.shiftNextStation(); | ||
int actual = radioman.getCurrentStation(); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = {"equivalencePartitionInLimits,5,4", | ||
"equivalencePartitionOutLimitsBelow,-20,9", | ||
"equivalencePartitionOutLimitsAbove,20,9", | ||
"onMinLimit,0,9", | ||
"onMaxLimit,9,8", | ||
"boundaryOutBelowMinLimit,-1,9", | ||
"boundaryOutAboveMaxLimit,10,9", | ||
"boundaryInNearMinLimit,1,0", | ||
"boundaryInNearMaxLimit,8,7"}) | ||
void shouldShiftPrevStation(String testcase, int currentStation, int expected) { | ||
radioman.setCurrentStation(currentStation); | ||
radioman.shiftPrevStation(); | ||
int actual = radioman.getCurrentStation(); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = {"equivalencePartitionInLimits,5,6", | ||
"equivalencePartitionOutLimitsBelow,-20,1", | ||
"equivalencePartitionOutLimitsAbove,20,1", | ||
"onMinLimit,0,1", | ||
"onMaxLimit,10,10", | ||
"boundaryOutBelowMinLimit,-1,1", | ||
"boundaryOutAboveMaxLimit,11,1", | ||
"boundaryInNearMinLimit,1,2", | ||
"boundaryInNearMaxLimit,9,10"}) | ||
void shouldIncreaseVolume(String testcase, int currentVolume, int expected) { | ||
radioman.setCurrentVolume(currentVolume); | ||
radioman.increaseVolume(); | ||
int actual = radioman.getCurrentVolume(); | ||
assertEquals(expected, actual); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = {"equivalencePartitionInLimits,5,4", | ||
"equivalencePartitionOutLimitsBelow,-20,0", | ||
"equivalencePartitionOutLimitsAbove,20,0", | ||
"onMinLimit,0,0", | ||
"onMaxLimit,10,9", | ||
"boundaryOutBelowMinLimit,-1,0", | ||
"boundaryOutAboveMaxLimit,11,0", | ||
"boundaryInNearMinLimit,1,0", | ||
"boundaryInNearMaxLimit,9,8"}) | ||
void shouldDecreaseVolume(String testcase, int currentVolume, int expected) { | ||
radioman.setCurrentVolume(currentVolume); | ||
radioman.decreaseVolume(); | ||
int actual = radioman.getCurrentVolume(); | ||
assertEquals(expected, actual); | ||
} | ||
} |