diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..afe4fe301 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# 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://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +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 + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/README.md b/README.md index e26e034fc..e3d228995 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,14 @@ The figure below illustrates this behavior using an example. 1. As the joystick remains at a positive value, the reference speed is incremented again. 1. However, it reaches the speed limit so in the next step it is not incremented even though the joystick still has a positive value. 1. Later, the joystick is set to a negative position for one time unit, making the reference speed to decrease as well. + + +# Rete labor feladat A branch + +1. Környezet kialakítása +2. Inicializálás +3. Markdown feladatok +4. *Github Flow* feladatok +5. Konfliktus **merge** esetén +6. CI feladatok +7. Külső függőségek hozzáadaása diff --git a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java index 06649d278..21a729402 100644 --- a/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java +++ b/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java @@ -8,6 +8,10 @@ public class TrainControllerImpl implements TrainController { private int referenceSpeed = 0; private int speedLimit = 0; + public TrainControllerImpl(){ + followSpeed(); + } + @Override public void followSpeed() { if (referenceSpeed < 0) { @@ -46,4 +50,8 @@ public void setJoystickPosition(int joystickPosition) { this.step = joystickPosition; } + @Override + public void emergencyBrake(){ + referenceSpeed = 0; + } } diff --git a/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..7f5a1ef4a --- /dev/null +++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/controller/TrainControllerImpl.class diff --git a/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..85fce0e48 --- /dev/null +++ b/train-controller/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-controller/src/main/java/hu/bme/mit/train/controller/TrainControllerImpl.java diff --git a/train-interfaces/pom.xml b/train-interfaces/pom.xml index 5ce3ab115..09f9b7849 100644 --- a/train-interfaces/pom.xml +++ b/train-interfaces/pom.xml @@ -10,4 +10,11 @@ hu.bme.mit.train 0.5.0-SNAPSHOT + + + com.google.guava + guava + 32.1.3-jre + + \ No newline at end of file diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java index c8adca066..e4e11ab92 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java @@ -10,4 +10,6 @@ public interface TrainController { void setJoystickPosition(int joystickPosition); + void emergencyBrake(); + } diff --git a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java index 298173025..fdce275f3 100644 --- a/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java +++ b/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java @@ -1,4 +1,7 @@ package hu.bme.mit.train.interfaces; +import com.google.common.collect.Table; +import java.time.LocalTime; +import com.google.common.collect.HashBasedTable; public interface TrainSensor { @@ -6,4 +9,8 @@ public interface TrainSensor { void overrideSpeedLimit(int speedLimit); + void tachoGraf(); + + int size(); + } diff --git a/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..248759f35 --- /dev/null +++ b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +hu/bme/mit/train/interfaces/TrainController.class +hu/bme/mit/train/interfaces/TrainSensor.class +hu/bme/mit/train/interfaces/TrainUser.class diff --git a/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..e56ac5e6e --- /dev/null +++ b/train-interfaces/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +/home/cloud/Desktop/retelab/retelab/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainUser.java +/home/cloud/Desktop/retelab/retelab/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainSensor.java +/home/cloud/Desktop/retelab/retelab/train-interfaces/src/main/java/hu/bme/mit/train/interfaces/TrainController.java diff --git a/train-sensor/pom.xml b/train-sensor/pom.xml index 0b50214b9..8a7c078a8 100644 --- a/train-sensor/pom.xml +++ b/train-sensor/pom.xml @@ -36,5 +36,10 @@ 0.8.7 test + + com.google.guava + guava + 32.1.3-jre + \ No newline at end of file diff --git a/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java b/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java index 4a640d1dd..7bb2ee33f 100644 --- a/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java +++ b/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java @@ -3,16 +3,23 @@ import hu.bme.mit.train.interfaces.TrainController; import hu.bme.mit.train.interfaces.TrainSensor; import hu.bme.mit.train.interfaces.TrainUser; +import com.google.common.collect.Table; +import java.time.LocalTime; +import com.google.common.collect.HashBasedTable; + public class TrainSensorImpl implements TrainSensor { private TrainController controller; private TrainUser user; private int speedLimit = 5; + private Table courseSeatTable; + public TrainSensorImpl(TrainController controller, TrainUser user) { this.controller = controller; this.user = user; + courseSeatTable = HashBasedTable.create(); } @Override @@ -26,4 +33,21 @@ public void overrideSpeedLimit(int speedLimit) { controller.setSpeedLimit(speedLimit); } + @Override + public void tachoGraf(){ + + + courseSeatTable.put(LocalTime.now(), 10, 12); + } + + public int size() + { + return courseSeatTable.size(); + } + } + + + + + diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..5c6a37510 --- /dev/null +++ b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/sensor/TrainSensorImpl.class diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..1e73fb0bf --- /dev/null +++ b/train-sensor/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-sensor/src/main/java/hu/bme/mit/train/sensor/TrainSensorImpl.java diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000..0ad3f3de4 --- /dev/null +++ b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/sensor/TrainSensorTest.class diff --git a/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000..91390c22e --- /dev/null +++ b/train-sensor/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.java diff --git a/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml b/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml new file mode 100644 index 000000000..12ee398ef --- /dev/null +++ b/train-sensor/target/surefire-reports/TEST-hu.bme.mit.train.sensor.TrainSensorTest.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt b/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt new file mode 100644 index 000000000..7d8e0f52d --- /dev/null +++ b/train-sensor/target/surefire-reports/hu.bme.mit.train.sensor.TrainSensorTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: hu.bme.mit.train.sensor.TrainSensorTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.177 sec diff --git a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java index 04ae3dac0..b63ac2178 100644 --- a/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java +++ b/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java @@ -1,5 +1,7 @@ package hu.bme.mit.train.system; +import java.time.LocalDate; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -9,6 +11,7 @@ import hu.bme.mit.train.interfaces.TrainUser; import hu.bme.mit.train.system.TrainSystem; + public class TrainSystemTest { TrainController controller; @@ -50,5 +53,28 @@ public void OverridingJoystickPositionToNegative_SetsReferenceSpeedToZero() { Assert.assertEquals(0, controller.getReferenceSpeed()); } + @Test + public void emergencyBrakeTest() { + user.overrideJoystickPosition(0); + Assert.assertEquals(0, controller.getReferenceSpeed()); + } + + @Test + public void Test() { + sensor.overrideSpeedLimit(10); + + Assert.assertEquals(0, controller.getReferenceSpeed()); + } + + @Test + public void hetesFeladatTest() { + int meret = sensor.size(); + Assert.assertEquals(0, meret); + + sensor.tachoGraf(); + int meret2 = sensor.size(); + Assert.assertEquals(1, meret2); + + } } diff --git a/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..104d0eff5 --- /dev/null +++ b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/system/TrainSystem.class diff --git a/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..2d3e79767 --- /dev/null +++ b/train-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-system/src/main/java/hu/bme/mit/train/system/TrainSystem.java diff --git a/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000..f347beb05 --- /dev/null +++ b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/system/TrainSystemTest.class diff --git a/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000..442152824 --- /dev/null +++ b/train-system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-system/src/test/java/hu/bme/mit/train/system/TrainSystemTest.java diff --git a/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml b/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml new file mode 100644 index 000000000..71f5da830 --- /dev/null +++ b/train-system/target/surefire-reports/TEST-hu.bme.mit.train.system.TrainSystemTest.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt b/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt new file mode 100644 index 000000000..18e0b4127 --- /dev/null +++ b/train-system/target/surefire-reports/hu.bme.mit.train.system.TrainSystemTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: hu.bme.mit.train.system.TrainSystemTest +------------------------------------------------------------------------------- +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.178 sec diff --git a/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java b/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java index 93d3b2e59..3eda1da6b 100644 --- a/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java +++ b/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java @@ -26,6 +26,8 @@ public int getJoystickPosition() { public void overrideJoystickPosition(int joystickPosition) { this.joystickPosition = joystickPosition; controller.setJoystickPosition(joystickPosition); + } + } diff --git a/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000..f84f69174 --- /dev/null +++ b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +hu/bme/mit/train/user/TrainUserImpl.class diff --git a/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000..28cdb365f --- /dev/null +++ b/train-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/cloud/Desktop/retelab/retelab/train-user/src/main/java/hu/bme/mit/train/user/TrainUserImpl.java