-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
912917f
commit b6abcfb
Showing
20 changed files
with
1,140 additions
and
45 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
52 changes: 52 additions & 0 deletions
52
subprojects/computer-types/src/test/java/hu/bme/mit/ase/cps/types/computers/LaptopTest.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,52 @@ | ||
package hu.bme.mit.ase.cps.types.computers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class LaptopTest { | ||
|
||
@Test | ||
@DisplayName("Laptop should be constructable with name and IP parameters") | ||
void laptopShouldBeConstructable() { | ||
new Laptop("laptop-1", "192.168.0.104"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Laptop should correctly return name and IP after construction") | ||
void laptopConstructorShouldSetFields() { | ||
var laptop = new Laptop("laptop-1", "192.168.0.104"); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("laptop-1", laptop.getName(), "Expected Laptop name to be 'laptop-1', but was '" + laptop.getName() + "'"), | ||
() -> Assertions.assertEquals("192.168.0.104", laptop.getIp(), "Expected Laptop IP to be '192.168.0.104', but was '" + laptop.getIp() + "'") | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("Laptop should return correct OS") | ||
void testLaptopGetOs() { | ||
var laptop = new Laptop("laptop-1", "192.168.0.104"); | ||
Assertions.assertEquals("Windows10", laptop.getOs(), "Expected Laptop OS to be 'Windows10', but was '" + laptop.getOs() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Laptop should return correct description") | ||
void testLaptopGetDescription() { | ||
var laptop = new Laptop("laptop-1", "192.168.0.104"); | ||
Assertions.assertEquals("Portable computer for professional and personal use", laptop.getDescription(), | ||
"Expected Laptop description to be 'Portable computer for professional and personal use', but was '" + laptop.getDescription() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Laptop should return correct resources") | ||
void testLaptopGetResources() { | ||
var laptop = new Laptop("laptop-1", "192.168.0.104"); | ||
var resources = laptop.getResources(); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("8GB", resources.getMemory(), "Expected Laptop memory to be '8GB', but was '" + resources.getMemory() + "'"), | ||
() -> Assertions.assertEquals("4-core Intel i5", resources.getCpu(), "Expected Laptop CPU to be '4-core Intel i5', but was '" + resources.getCpu() + "'"), | ||
() -> Assertions.assertEquals("256GB", resources.getStorage(), "Expected Laptop storage to be '256GB', but was '" + resources.getStorage() + "'") | ||
); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
subprojects/computer-types/src/test/java/hu/bme/mit/ase/cps/types/computers/PCTest.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,52 @@ | ||
package hu.bme.mit.ase.cps.types.computers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PCTest { | ||
|
||
@Test | ||
@DisplayName("PC should be constructable with name and IP parameters") | ||
void pcShouldBeConstructable() { | ||
new PC("pc-1", "192.168.0.103"); | ||
} | ||
|
||
@Test | ||
@DisplayName("PC should correctly return name and IP after construction") | ||
void pcConstructorShouldSetFields() { | ||
var pc = new PC("pc-1", "192.168.0.103"); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("pc-1", pc.getName(), "Expected PC name to be 'pc-1', but was '" + pc.getName() + "'"), | ||
() -> Assertions.assertEquals("192.168.0.103", pc.getIp(), "Expected PC IP to be '192.168.0.103', but was '" + pc.getIp() + "'") | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("PC should return correct OS") | ||
void testPCGetOs() { | ||
var pc = new PC("pc-1", "192.168.0.103"); | ||
Assertions.assertEquals("UbuntuLinux", pc.getOs(), "Expected PC OS to be 'UbuntuLinux', but was '" + pc.getOs() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("PC should return correct description") | ||
void testPCGetDescription() { | ||
var pc = new PC("pc-1", "192.168.0.103"); | ||
Assertions.assertEquals("Standard desktop computer for general-purpose use", pc.getDescription(), | ||
"Expected PC description to be 'Standard desktop computer for general-purpose use', but was '" + pc.getDescription() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("PC should return correct resources") | ||
void testPCGetResources() { | ||
var pc = new PC("pc-1", "192.168.0.103"); | ||
var resources = pc.getResources(); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("16GB", resources.getMemory(), "Expected PC memory to be '16GB', but was '" + resources.getMemory() + "'"), | ||
() -> Assertions.assertEquals("8-core Intel i7", resources.getCpu(), "Expected PC CPU to be '8-core Intel i7', but was '" + resources.getCpu() + "'"), | ||
() -> Assertions.assertEquals("512GB", resources.getStorage(), "Expected PC storage to be '512GB', but was '" + resources.getStorage() + "'") | ||
); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...cts/computer-types/src/test/java/hu/bme/mit/ase/cps/types/computers/RaspberryPi3Test.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,52 @@ | ||
package hu.bme.mit.ase.cps.types.computers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class RaspberryPi3Test { | ||
|
||
@Test | ||
@DisplayName("RaspberryPi3 should be constructable with name and IP parameters") | ||
void raspberryPi3ShouldBeConstructable() { | ||
new RaspberryPi3("pi3-1", "192.168.0.101"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi3 should correctly return name and IP after construction") | ||
void raspberryPi3ConstructorShouldSetFields() { | ||
var pi3 = new RaspberryPi3("pi3-1", "192.168.0.101"); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("pi3-1", pi3.getName(), "Expected RaspberryPi3 name to be 'pi3-1', but was '" + pi3.getName() + "'"), | ||
() -> Assertions.assertEquals("192.168.0.101", pi3.getIp(), "Expected RaspberryPi3 IP to be '192.168.0.101', but was '" + pi3.getIp() + "'") | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi3 should return correct OS") | ||
void testRaspberryPi3GetOs() { | ||
var pi3 = new RaspberryPi3("pi3-1", "192.168.0.101"); | ||
Assertions.assertEquals("RaspberryPiOS", pi3.getOs(), "Expected RaspberryPi3 OS to be 'RaspberryPiOS', but was '" + pi3.getOs() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi3 should return correct description") | ||
void testRaspberryPi3GetDescription() { | ||
var pi3 = new RaspberryPi3("pi3-1", "192.168.0.101"); | ||
Assertions.assertEquals("Entry-level computer for lightweight tasks", pi3.getDescription(), | ||
"Expected RaspberryPi3 description to be 'Entry-level computer for lightweight tasks', but was '" + pi3.getDescription() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi3 should return correct resources") | ||
void testRaspberryPi3GetResources() { | ||
var pi3 = new RaspberryPi3("pi3-1", "192.168.0.101"); | ||
var resources = pi3.getResources(); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("1GB", resources.getMemory(), "Expected RaspberryPi3 memory to be '1GB', but was '" + resources.getMemory() + "'"), | ||
() -> Assertions.assertEquals("4-core ARM Cortex-A53", resources.getCpu(), "Expected RaspberryPi3 CPU to be '4-core ARM Cortex-A53', but was '" + resources.getCpu() + "'"), | ||
() -> Assertions.assertEquals("16GB", resources.getStorage(), "Expected RaspberryPi3 storage to be '16GB', but was '" + resources.getStorage() + "'") | ||
); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...cts/computer-types/src/test/java/hu/bme/mit/ase/cps/types/computers/RaspberryPi4Test.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,52 @@ | ||
package hu.bme.mit.ase.cps.types.computers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class RaspberryPi4Test { | ||
|
||
@Test | ||
@DisplayName("RaspberryPi4 should be constructable with name and IP parameters") | ||
void raspberryPi4ShouldBeConstructable() { | ||
new RaspberryPi4("pi4-1", "192.168.0.102"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi4 should correctly return name and IP after construction") | ||
void raspberryPi4ConstructorShouldSetFields() { | ||
var pi4 = new RaspberryPi4("pi4-1", "192.168.0.102"); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("pi4-1", pi4.getName(), "Expected RaspberryPi4 name to be 'pi4-1', but was '" + pi4.getName() + "'"), | ||
() -> Assertions.assertEquals("192.168.0.102", pi4.getIp(), "Expected RaspberryPi4 IP to be '192.168.0.102', but was '" + pi4.getIp() + "'") | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi4 should return correct OS") | ||
void testRaspberryPi4GetOs() { | ||
var pi4 = new RaspberryPi4("pi4-1", "192.168.0.102"); | ||
Assertions.assertEquals("RaspberryPiOS", pi4.getOs(), "Expected RaspberryPi4 OS to be 'RaspberryPiOS', but was '" + pi4.getOs() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi4 should return correct description") | ||
void testRaspberryPi4GetDescription() { | ||
var pi4 = new RaspberryPi4("pi4-1", "192.168.0.102"); | ||
Assertions.assertEquals("Improved model with enhanced performance", pi4.getDescription(), | ||
"Expected RaspberryPi4 description to be 'Improved model with enhanced performance', but was '" + pi4.getDescription() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("RaspberryPi4 should return correct resources") | ||
void testRaspberryPi4GetResources() { | ||
var pi4 = new RaspberryPi4("pi4-1", "192.168.0.102"); | ||
var resources = pi4.getResources(); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("4GB", resources.getMemory(), "Expected RaspberryPi4 memory to be '4GB', but was '" + resources.getMemory() + "'"), | ||
() -> Assertions.assertEquals("4-core ARM Cortex-A72", resources.getCpu(), "Expected RaspberryPi4 CPU to be '4-core ARM Cortex-A72', but was '" + resources.getCpu() + "'"), | ||
() -> Assertions.assertEquals("32GB", resources.getStorage(), "Expected RaspberryPi4 storage to be '32GB', but was '" + resources.getStorage() + "'") | ||
); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
subprojects/computer-types/src/test/java/hu/bme/mit/ase/cps/types/computers/ServerTest.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,52 @@ | ||
package hu.bme.mit.ase.cps.types.computers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ServerTest { | ||
|
||
@Test | ||
@DisplayName("Server should be constructable with name and IP parameters") | ||
void serverShouldBeConstructable() { | ||
new Server("server-1", "192.168.0.105"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Server should correctly return name and IP after construction") | ||
void serverConstructorShouldSetFields() { | ||
var server = new Server("server-1", "192.168.0.105"); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("server-1", server.getName(), "Expected Server name to be 'server-1', but was '" + server.getName() + "'"), | ||
() -> Assertions.assertEquals("192.168.0.105", server.getIp(), "Expected Server IP to be '192.168.0.105', but was '" + server.getIp() + "'") | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("Server should return correct OS") | ||
void testServerGetOs() { | ||
var server = new Server("server-1", "192.168.0.105"); | ||
Assertions.assertEquals("CentOS", server.getOs(), "Expected Server OS to be 'CentOS', but was '" + server.getOs() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Server should return correct description") | ||
void testServerGetDescription() { | ||
var server = new Server("server-1", "192.168.0.105"); | ||
Assertions.assertEquals("High-performance server for enterprise applications", server.getDescription(), | ||
"Expected Server description to be 'High-performance server for enterprise applications', but was '" + server.getDescription() + "'"); | ||
} | ||
|
||
@Test | ||
@DisplayName("Server should return correct resources") | ||
void testServerGetResources() { | ||
var server = new Server("server-1", "192.168.0.105"); | ||
var resources = server.getResources(); | ||
Assertions.assertAll( | ||
() -> Assertions.assertEquals("64GB", resources.getMemory(), "Expected Server memory to be '64GB', but was '" + resources.getMemory() + "'"), | ||
() -> Assertions.assertEquals("16-core AMD EPYC", resources.getCpu(), "Expected Server CPU to be '16-core AMD EPYC', but was '" + resources.getCpu() + "'"), | ||
() -> Assertions.assertEquals("2TB", resources.getStorage(), "Expected Server storage to be '2TB', but was '" + resources.getStorage() + "'") | ||
); | ||
} | ||
|
||
} |
50 changes: 44 additions & 6 deletions
50
subprojects/deployments/src/main/java/hu/bme/mit/ase/cps/deployments/CPS.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 |
---|---|---|
@@ -1,16 +1,54 @@ | ||
package hu.bme.mit.ase.cps.deployments; | ||
|
||
import hu.bme.mit.ase.cps.types.computers.Computer; | ||
import hu.bme.mit.ase.cps.types.software.Software; | ||
|
||
public abstract class CPS { | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public abstract void installSoftware(Computer computer, String software); | ||
record Connection(Computer source, Computer target) { } | ||
|
||
public abstract void deployComputer(Computer computer); | ||
public class CPS { | ||
|
||
public abstract void connectComputers(Computer source, Computer target); | ||
private final List<Computer> deployedComputers = new ArrayList<>(); | ||
private final Set<Connection> connections = new HashSet<>(); | ||
|
||
public abstract boolean checkReachability(Computer source, Computer target); | ||
public void deployComputer(Computer computer) { | ||
deployedComputers.add(computer); | ||
} | ||
|
||
public List<Computer> getDeployedComputers() { | ||
return deployedComputers; | ||
} | ||
|
||
public Computer getComputerByName(String name) { | ||
return getDeployedComputers().stream().filter((computer -> computer.getName().equals(name))).findFirst().orElse(null); | ||
} | ||
|
||
public void installSoftware(Computer computer, String software) { | ||
|
||
} | ||
|
||
public void connectComputers(Computer source, Computer target) { | ||
connections.add(new Connection(source, target)); | ||
connections.add(new Connection(target, source)); | ||
} | ||
|
||
public boolean checkReachability(Computer source, Computer target) { | ||
if (source.equals(target)) { | ||
return true; | ||
} | ||
|
||
return hasConnection(source, target); | ||
} | ||
|
||
public boolean hasConnection(Computer a, Computer b) { | ||
return connections.contains(new Connection(a, b)); | ||
} | ||
|
||
public int getNumberOfConnections() { | ||
return connections.size() / 2; | ||
} | ||
|
||
} |
Oops, something went wrong.