Skip to content

Commit

Permalink
Merge branch '128-add-group-id-to-package-naming' into 'master'
Browse files Browse the repository at this point in the history
Issue #128: Restructure packages to follow Java naming convention

Closes #128

See merge request it1901/groups-2023/gr2338/gr2338!120
  • Loading branch information
grannes1000 committed Nov 8, 2023
2 parents a350fe9 + 96aec8d commit 7d6e7d0
Show file tree
Hide file tree
Showing 63 changed files with 491 additions and 475 deletions.
6 changes: 5 additions & 1 deletion vendmachtrack/config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>

<module name="PackageName">
<property name="format" value="^[a-z0-9]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/>
</module>

<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
Expand Down
8 changes: 4 additions & 4 deletions vendmachtrack/config/spotbugs-exclude-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<!-- This is standard practice in Spring Boot and generally not considered a security risk. -->
<!-- The constructor uses the @Autowired annotation for dependency injection. -->
<Match>
<Class name="vendmachtrack.springboot.controller.MachineTrackerController"/>
<Class name="gr2338.vendmachtrack.springboot.controller.MachineTrackerController"/>
<Method name="&lt;init&gt;"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
<Match>
<Class name="vendmachtrack.springboot.service.MachineTrackerService"/>
<Class name="gr2338.vendmachtrack.springboot.service.MachineTrackerService"/>
<Method name="&lt;init&gt;"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
Expand All @@ -19,12 +19,12 @@
<!-- The RefillController class needs to store the access object in this way for it to be used as a shared resource -->
<!-- This is standard practice for the service pattern -->
<Match>
<Class name="vendmachtrack.ui.access.AccessService"/>
<Class name="gr2338.vendmachtrack.ui.access.AccessService"/>
<Method name="getAccess"/>
<Bug pattern="EI_EXPOSE_REP"/>
</Match>
<!-- <Match>-->
<!-- <Class name="vendmachtrack.ui.controller.RefillController"/>-->
<!-- <Class name="gr2338.vendmachtrack.controller.ui.RefillController"/>-->
<!-- <Method name="setMachineTrackerAccess"/>-->
<!-- <Bug pattern="EI_EXPOSE_REP2"/>-->
<!-- </Match>-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

/**
* This class encapsulates the concept of an item within a vending machine.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

import java.util.HashMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.core.util;
package gr2338.vendmachtrack.core.util;

import de.mkammerer.argon2.Argon2;
import de.mkammerer.argon2.Argon2Factory;
Expand Down
8 changes: 4 additions & 4 deletions vendmachtrack/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
requires com.sun.jna;

// Necessary exports to other modules of this project.
exports vendmachtrack.core.model to vendmachtrack.jsonio, vendmachtrack.ui, vendmachtrack.springboot;
exports gr2338.vendmachtrack.core.model to vendmachtrack.jsonio, vendmachtrack.ui, vendmachtrack.springboot;

// Opening a package is a major decision.
// After a lot of research and attempts, it seems implementing TypeAdapter is
// the only way to avoid opening the package to Gson.
// See readme documentation for more information on this.
opens vendmachtrack.core.model to com.google.gson;
exports vendmachtrack.core.util to vendmachtrack.jsonio, vendmachtrack.springboot, vendmachtrack.ui;
opens vendmachtrack.core.util to com.google.gson;
opens gr2338.vendmachtrack.core.model to com.google.gson;
exports gr2338.vendmachtrack.core.util to vendmachtrack.jsonio, vendmachtrack.springboot, vendmachtrack.ui;
opens gr2338.vendmachtrack.core.util to com.google.gson;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

import gr2338.vendmachtrack.core.model.Item;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vendmachtrack.core.model;
package gr2338.vendmachtrack.core.model;

import gr2338.vendmachtrack.core.model.VendingMachine;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vendmachtrack.core.util;
package gr2338.vendmachtrack.core.util;

import gr2338.vendmachtrack.core.util.PasswordHandler;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down
2 changes: 1 addition & 1 deletion vendmachtrack/integrationtests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.4</version>
<configuration>
<mainClass>vendmachtrack.springboot.SpringbootApplication</mainClass>
<mainClass>gr2338.vendmachtrack.springboot.SpringbootApplication</mainClass>
<jmxPort>7070</jmxPort>
<!-- <fork>true</fork>-->
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vendmachtrack.integrationtests;
package gr2338.vendmachtrack.integrationtests;

import gr2338.vendmachtrack.ui.App;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextArea;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class IntegrationUITestIT extends ApplicationTest {
@Override
public void start(Stage stage) throws Exception {

new vendmachtrack.ui.App().start(stage);
new App().start(stage);
}

/**
Expand Down Expand Up @@ -93,7 +94,7 @@ private void centerCurrentStage() {
* <p>
* <p>
* Step 2: VendAppController
*
*
* <ol>
* <li>Add a vending machine with ID 1001 and location "Beijing".</li>
* <li>Verify that the vending machine was added.</li>
Expand Down Expand Up @@ -125,8 +126,8 @@ private void centerCurrentStage() {
* </ol>
*
* <p>
*
*
* <p>
* <p>
* Step 5: passwordHandlerController:
* <ol>
* <li>Enter a wrong password and attempt to confirm it.</li>
Expand Down Expand Up @@ -177,7 +178,7 @@ public void integrationTestFlow() throws InterruptedException {

// Assert that the vending machine was added to the choice box
@SuppressWarnings("unchecked") // Suppressing unchecked cast warning because we are certain that the queried
// object is of type ChoiceBox<String>.
// object is of type ChoiceBox<String>.
ChoiceBox<String> choiceBox = (ChoiceBox<String>) lookup("#menuBar").queryAs(ChoiceBox.class);
String expectedItem = "id: 1001 (Beijing)";
assertTrue(choiceBox.getItems().contains(expectedItem));
Expand Down Expand Up @@ -281,7 +282,7 @@ public void testIntegrationFlow2() {

// Assert that the vending machine was removed from the choice box
@SuppressWarnings("unchecked") // Suppressing unchecked cast warning because we are certain that the queried
// object is of type ChoiceBox<String>.
// object is of type ChoiceBox<String>.
ChoiceBox<String> choiceBox = (ChoiceBox<String>) lookup("#menuBar").queryAs(ChoiceBox.class);
assertFalse(choiceBox.getItems().contains("id: 1001 (Beijing)"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package vendmachtrack.jsonio;
package gr2338.vendmachtrack.jsonio;

import vendmachtrack.core.model.MachineTracker;
import vendmachtrack.jsonio.internal.FromJson;
import vendmachtrack.jsonio.internal.ToJson;
import gr2338.vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.jsonio.internal.FromJson;
import gr2338.vendmachtrack.jsonio.internal.ToJson;

/**
* The {@code VendmachtrackPersistence} class offers a high-level interface for persisting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vendmachtrack.jsonio.internal;
package gr2338.vendmachtrack.jsonio.internal;

import com.google.gson.Gson;
import vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.core.model.MachineTracker;

import java.io.BufferedReader;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vendmachtrack.jsonio.internal;
package gr2338.vendmachtrack.jsonio.internal;

import com.google.gson.Gson;
import vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.core.model.MachineTracker;

import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
Expand Down
4 changes: 2 additions & 2 deletions vendmachtrack/jsonio/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module vendmachtrack.jsonio {
// Allows the UI application to interact directly with the tracker file.
exports vendmachtrack.jsonio.internal to vendmachtrack.ui;
exports gr2338.vendmachtrack.jsonio.internal to vendmachtrack.ui;

// Weak encapsulation, but we haven't managed to find the unnamed module that is dependent on this module.
// This will be worked more on in a later release.
exports vendmachtrack.jsonio;
exports gr2338.vendmachtrack.jsonio;

requires vendmachtrack.core;
requires com.google.gson;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package vendmachtrack.jsonio.internal;
package gr2338.vendmachtrack.jsonio.internal;

import gr2338.vendmachtrack.jsonio.internal.FromJson;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.core.model.MachineTracker;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package vendmachtrack.jsonio.internal;
package gr2338.vendmachtrack.jsonio.internal;

import gr2338.vendmachtrack.jsonio.internal.ToJson;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import vendmachtrack.core.model.MachineTracker;
import vendmachtrack.core.model.VendingMachine;
import gr2338.vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.core.model.VendingMachine;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
6 changes: 3 additions & 3 deletions vendmachtrack/springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.4</version>
<configuration>
<mainClass>vendmachtrack.springboot.SpringbootApplication</mainClass>
<mainClass>gr2338.vendmachtrack.springboot.SpringbootApplication</mainClass>
</configuration>
</plugin>

Expand All @@ -104,7 +104,7 @@
<!-- Transformer for the manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>vendmachtrack.springboot.SpringbootApplication</mainClass>
<mainClass>gr2338.vendmachtrack.springboot.SpringbootApplication</mainClass>
</transformer>
<!-- Transformer for service resources -->
<transformer
Expand Down Expand Up @@ -132,7 +132,7 @@
<vendor>gr2338</vendor>
<input>${project.build.directory}/</input>
<mainJar>${project.build.finalName}-shaded.jar</mainJar>
<mainClass>vendmachtrack.springboot.SpringbootApplication</mainClass>
<mainClass>gr2338.vendmachtrack.springboot.SpringbootApplication</mainClass>
<destination>${project.build.directory}/jpackage/</destination>
<javaOptions>
<option>-Dfile.encoding=UTF-8</option>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot;
package gr2338.vendmachtrack.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.controller;
package gr2338.vendmachtrack.springboot.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.controller;
package gr2338.vendmachtrack.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
Expand All @@ -10,7 +10,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import vendmachtrack.springboot.service.MachineTrackerService;
import gr2338.vendmachtrack.springboot.service.MachineTrackerService;

import java.util.HashMap;

Expand Down Expand Up @@ -81,8 +81,8 @@ public ResponseEntity<HashMap<String, Integer>> getInventory(@PathVariable("id")
*/
@PutMapping("/{id}/add")
public ResponseEntity<HashMap<String, Integer>> addItem(@PathVariable("id") final int id,
@RequestParam final String item,
@RequestParam final int quantity) {
@RequestParam final String item,
@RequestParam final int quantity) {
return ResponseEntity.ok(machineTrackerService.addItem(id, item, quantity));
}

Expand All @@ -96,8 +96,8 @@ public ResponseEntity<HashMap<String, Integer>> addItem(@PathVariable("id") fina
*/
@PutMapping("/{id}/remove")
public ResponseEntity<HashMap<String, Integer>> removeItem(@PathVariable("id") final int id,
@RequestParam final String item,
@RequestParam final int quantity) {
@RequestParam final String item,
@RequestParam final int quantity) {
return ResponseEntity.ok(machineTrackerService.removeItem(id, item, quantity));
}

Expand All @@ -110,7 +110,7 @@ public ResponseEntity<HashMap<String, Integer>> removeItem(@PathVariable("id") f
*/
@PostMapping("/add")
public ResponseEntity<HashMap<Integer, String>> addVendMach(@RequestParam final int id,
@RequestParam final String location) {
@RequestParam final String location) {
return ResponseEntity.ok(machineTrackerService.addVendMach(id, location));
}

Expand All @@ -134,7 +134,7 @@ public ResponseEntity<HashMap<Integer, String>> removeVendMach(@PathVariable("id
*/
@PutMapping("/{id}")
public ResponseEntity<HashMap<Integer, String>> changeLocation(@PathVariable("id") final int id,
@RequestParam final String location) {
@RequestParam final String location) {
return ResponseEntity.ok(machineTrackerService.changeLocation(id, location));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.exception;
package gr2338.vendmachtrack.springboot.exception;

import java.util.Date;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.exception;
package gr2338.vendmachtrack.springboot.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.exception;
package gr2338.vendmachtrack.springboot.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vendmachtrack.springboot.exception;
package gr2338.vendmachtrack.springboot.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package vendmachtrack.springboot.repository;
package gr2338.vendmachtrack.springboot.repository;

import org.springframework.stereotype.Repository;
import vendmachtrack.core.model.MachineTracker;
import vendmachtrack.core.model.VendingMachine;
import vendmachtrack.jsonio.VendmachtrackPersistence;
import gr2338.vendmachtrack.core.model.MachineTracker;
import gr2338.vendmachtrack.core.model.VendingMachine;
import gr2338.vendmachtrack.jsonio.VendmachtrackPersistence;

/**
* Repository class responsible for handling operations related to the
Expand Down
Loading

0 comments on commit 7d6e7d0

Please sign in to comment.