Punching screen controller created - migrated initview and addcase endpoints
This commit is contained in:
47
cygnus-lib/pom.xml
Normal file
47
cygnus-lib/pom.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.cygnus</groupId>
|
||||
<artifactId>cygnus-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>cygnus-lib</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Cygnus Shared Library</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
71
cygnus-lib/src/main/java/lib/constants/ApplicationError.java
Normal file
71
cygnus-lib/src/main/java/lib/constants/ApplicationError.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package lib.constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Canonical user-facing errors shared by Cygnus applications. */
|
||||
public enum ApplicationError {
|
||||
BAD_REQUEST(400, "HTTP-400", "Invalid request",
|
||||
"Cygnus could not process the submitted request.",
|
||||
"Review the supplied information and try again."),
|
||||
SESSION_REQUIRED(401, "AUTH-401", "Sign in required",
|
||||
"Your session is missing or has expired.",
|
||||
"Sign in again to continue securely."),
|
||||
ACCESS_DENIED(403, "AUTH-403", "Access denied",
|
||||
"You do not have permission to open this page.",
|
||||
"Contact your administrator if this feature should be available to you."),
|
||||
PAGE_NOT_FOUND(404, "HTTP-404", "Page not found",
|
||||
"The requested page could not be found.",
|
||||
"Check the address or return to the application dashboard."),
|
||||
METHOD_NOT_ALLOWED(405, "HTTP-405", "Action not allowed",
|
||||
"This page does not support the requested action.",
|
||||
"Return to the previous page and try an available action."),
|
||||
CONFLICT(409, "HTTP-409", "Request conflict",
|
||||
"The request conflicts with the current state of the data.",
|
||||
"Refresh the page and try again."),
|
||||
PAYLOAD_TOO_LARGE(413, "HTTP-413", "File is too large",
|
||||
"The submitted content exceeds the permitted size.",
|
||||
"Reduce the file size and try again."),
|
||||
TOO_MANY_REQUESTS(429, "HTTP-429", "Too many requests",
|
||||
"Cygnus has received too many requests in a short period.",
|
||||
"Wait briefly before trying again."),
|
||||
INTERNAL_SERVER_ERROR(500, "HTTP-500", "Something went wrong",
|
||||
"Cygnus could not complete your request.",
|
||||
"Try again. If the issue continues, share the reference ID with support."),
|
||||
BAD_GATEWAY(502, "HTTP-502", "Service response unavailable",
|
||||
"A required service returned an invalid response.",
|
||||
"Try again shortly. If the issue continues, contact support."),
|
||||
SERVICE_UNAVAILABLE(503, "HTTP-503", "Service temporarily unavailable",
|
||||
"A required Cygnus service is currently unavailable.",
|
||||
"Wait briefly and try again."),
|
||||
GATEWAY_TIMEOUT(504, "HTTP-504", "Service response timed out",
|
||||
"A required service took too long to respond.",
|
||||
"Try the request again shortly.");
|
||||
|
||||
private final int httpStatus;
|
||||
private final String code;
|
||||
private final String title;
|
||||
private final String message;
|
||||
private final String description;
|
||||
|
||||
ApplicationError(
|
||||
int httpStatus, String code, String title, String message, String description) {
|
||||
this.httpStatus = httpStatus;
|
||||
this.code = code;
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public static ApplicationError fromHttpStatus(int status) {
|
||||
return Arrays.stream(values())
|
||||
.filter(error -> error.httpStatus == status)
|
||||
.findFirst()
|
||||
.orElse(INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
public int getHttpStatus() { return httpStatus; }
|
||||
public String getCode() { return code; }
|
||||
public String getTitle() { return title; }
|
||||
public String getMessage() { return message; }
|
||||
public String getDescription() { return description; }
|
||||
}
|
||||
22
cygnus-lib/src/main/java/lib/models/CasePunching.java
Normal file
22
cygnus-lib/src/main/java/lib/models/CasePunching.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package lib.models;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CasePunching {
|
||||
private ErrorDetails errorDetails;
|
||||
private Map<String, String> options;
|
||||
private List<String> visibleSections;
|
||||
private Integer portfolioId;
|
||||
private Integer formMode;
|
||||
private String userId;
|
||||
private String dynamicFields;
|
||||
private String dynamicHtml;
|
||||
private String verificationCaseId;
|
||||
private String documentCaseId;
|
||||
}
|
||||
58
cygnus-lib/src/main/java/lib/models/ErrorDetails.java
Normal file
58
cygnus-lib/src/main/java/lib/models/ErrorDetails.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package lib.models;
|
||||
|
||||
import lib.constants.ApplicationError;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
|
||||
/** Dependency-free error information shared across Cygnus modules. */
|
||||
@Getter
|
||||
public final class ErrorDetails implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final int httpStatus;
|
||||
private final String errorCode;
|
||||
private final String title;
|
||||
private final String message;
|
||||
private final String description;
|
||||
private final String referenceId;
|
||||
private final Instant timestamp;
|
||||
|
||||
public ErrorDetails(ApplicationError error) {
|
||||
this(error.getHttpStatus(), error.getCode(), error.getTitle(),
|
||||
error.getMessage(), error.getDescription(),
|
||||
UUID.randomUUID().toString(), Instant.now());
|
||||
}
|
||||
|
||||
private ErrorDetails(
|
||||
int httpStatus,
|
||||
String errorCode,
|
||||
String title,
|
||||
String message,
|
||||
String description,
|
||||
String referenceId,
|
||||
Instant timestamp) {
|
||||
if (httpStatus < 400 || httpStatus > 599) {
|
||||
throw new IllegalArgumentException("HTTP error status must be between 400 and 599");
|
||||
}
|
||||
this.httpStatus = httpStatus;
|
||||
this.errorCode = required(errorCode, "errorCode");
|
||||
this.title = required(title, "title");
|
||||
this.message = required(message, "message");
|
||||
this.description = description == null ? "" : description.trim();
|
||||
this.referenceId = required(referenceId, "referenceId");
|
||||
this.timestamp = Objects.requireNonNull(timestamp, "timestamp");
|
||||
}
|
||||
|
||||
private static String required(String value, String name) {
|
||||
if (value == null || value.isBlank()) {
|
||||
throw new IllegalArgumentException(name + " is required");
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
}
|
||||
22
cygnus-lib/src/test/java/lib/models/ErrorDetailsTest.java
Normal file
22
cygnus-lib/src/test/java/lib/models/ErrorDetailsTest.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package lib.models;
|
||||
|
||||
import lib.constants.ApplicationError;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ErrorDetailsTest {
|
||||
@Test
|
||||
void createsAReusableErrorContract() {
|
||||
ErrorDetails details = new ErrorDetails(ApplicationError.ACCESS_DENIED);
|
||||
assertEquals(403, details.getHttpStatus());
|
||||
assertEquals("AUTH-403", details.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapsHttpStatusToCanonicalError() {
|
||||
assertEquals(ApplicationError.PAGE_NOT_FOUND, ApplicationError.fromHttpStatus(404));
|
||||
assertEquals(ApplicationError.INTERNAL_SERVER_ERROR,
|
||||
ApplicationError.fromHttpStatus(599));
|
||||
}
|
||||
}
|
||||
BIN
cygnus-lib/target/classes/lib/constants/ApplicationError.class
Normal file
BIN
cygnus-lib/target/classes/lib/constants/ApplicationError.class
Normal file
Binary file not shown.
BIN
cygnus-lib/target/classes/lib/models/CasePunching.class
Normal file
BIN
cygnus-lib/target/classes/lib/models/CasePunching.class
Normal file
Binary file not shown.
BIN
cygnus-lib/target/classes/lib/models/ErrorDetails.class
Normal file
BIN
cygnus-lib/target/classes/lib/models/ErrorDetails.class
Normal file
Binary file not shown.
BIN
cygnus-lib/target/cygnus-lib-1.0.0-SNAPSHOT.jar
Normal file
BIN
cygnus-lib/target/cygnus-lib-1.0.0-SNAPSHOT.jar
Normal file
Binary file not shown.
3
cygnus-lib/target/maven-archiver/pom.properties
Normal file
3
cygnus-lib/target/maven-archiver/pom.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
artifactId=cygnus-lib
|
||||
groupId=com.cygnus
|
||||
version=1.0.0-SNAPSHOT
|
||||
@@ -0,0 +1,3 @@
|
||||
lib/constants/ApplicationError.class
|
||||
lib/models/ErrorDetails.class
|
||||
lib/models/CasePunching.class
|
||||
@@ -0,0 +1,3 @@
|
||||
/Users/maddy/Projects/cygnus/matrix/cygnus-lib/src/main/java/lib/constants/ApplicationError.java
|
||||
/Users/maddy/Projects/cygnus/matrix/cygnus-lib/src/main/java/lib/models/CasePunching.java
|
||||
/Users/maddy/Projects/cygnus/matrix/cygnus-lib/src/main/java/lib/models/ErrorDetails.java
|
||||
@@ -0,0 +1 @@
|
||||
lib/models/ErrorDetailsTest.class
|
||||
@@ -0,0 +1 @@
|
||||
/Users/maddy/Projects/cygnus/matrix/cygnus-lib/src/test/java/lib/models/ErrorDetailsTest.java
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" version="3.0.2" name="lib.models.ErrorDetailsTest" time="0.025" tests="2" errors="0" skipped="0" failures="0">
|
||||
<properties>
|
||||
<property name="java.specification.version" value="25"/>
|
||||
<property name="sun.jnu.encoding" value="UTF-8"/>
|
||||
<property name="java.class.path" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/test-classes:/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/classes:/Users/maddy/.m2/repository/org/projectlombok/lombok/1.18.46/lombok-1.18.46.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter/5.12.2/junit-jupiter-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.12.2/junit-jupiter-api-5.12.2.jar:/Users/maddy/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/maddy/.m2/repository/org/junit/platform/junit-platform-commons/1.12.2/junit-platform-commons-1.12.2.jar:/Users/maddy/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.12.2/junit-jupiter-params-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.12.2/junit-jupiter-engine-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/platform/junit-platform-engine/1.12.2/junit-platform-engine-1.12.2.jar:"/>
|
||||
<property name="java.vm.vendor" value="Homebrew"/>
|
||||
<property name="sun.arch.data.model" value="64"/>
|
||||
<property name="java.vendor.url" value="https://github.com/Homebrew/homebrew-core/issues"/>
|
||||
<property name="os.name" value="Mac OS X"/>
|
||||
<property name="java.vm.specification.version" value="25"/>
|
||||
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
||||
<property name="user.country" value="US"/>
|
||||
<property name="sun.boot.library.path" value="/opt/homebrew/Cellar/openjdk/25.0.2/libexec/openjdk.jdk/Contents/Home/lib"/>
|
||||
<property name="sun.java.command" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/surefire/surefirebooter-20260801181214398_3.jar /Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/surefire 2026-08-01T18-12-14_354-jvmRun1 surefire-20260801181214398_1tmp surefire_0-20260801181214398_2tmp"/>
|
||||
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
||||
<property name="jdk.debug" value="release"/>
|
||||
<property name="surefire.test.class.path" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/test-classes:/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/classes:/Users/maddy/.m2/repository/org/projectlombok/lombok/1.18.46/lombok-1.18.46.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter/5.12.2/junit-jupiter-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.12.2/junit-jupiter-api-5.12.2.jar:/Users/maddy/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/maddy/.m2/repository/org/junit/platform/junit-platform-commons/1.12.2/junit-platform-commons-1.12.2.jar:/Users/maddy/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.12.2/junit-jupiter-params-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.12.2/junit-jupiter-engine-5.12.2.jar:/Users/maddy/.m2/repository/org/junit/platform/junit-platform-engine/1.12.2/junit-platform-engine-1.12.2.jar:"/>
|
||||
<property name="sun.cpu.endian" value="little"/>
|
||||
<property name="user.home" value="/Users/maddy"/>
|
||||
<property name="user.language" value="en"/>
|
||||
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
||||
<property name="java.version.date" value="2026-01-20"/>
|
||||
<property name="java.home" value="/opt/homebrew/Cellar/openjdk/25.0.2/libexec/openjdk.jdk/Contents/Home"/>
|
||||
<property name="file.separator" value="/"/>
|
||||
<property name="basedir" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib"/>
|
||||
<property name="java.vm.compressedOopsMode" value="Zero based"/>
|
||||
<property name="line.separator" value=" "/>
|
||||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
||||
<property name="java.specification.name" value="Java Platform API Specification"/>
|
||||
<property name="apple.awt.application.name" value="ForkedBooter"/>
|
||||
<property name="surefire.real.class.path" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib/target/surefire/surefirebooter-20260801181214398_3.jar"/>
|
||||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
||||
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
||||
<property name="java.runtime.version" value="25.0.2"/>
|
||||
<property name="user.name" value="maddy"/>
|
||||
<property name="stdout.encoding" value="UTF-8"/>
|
||||
<property name="path.separator" value=":"/>
|
||||
<property name="os.version" value="26.5.2"/>
|
||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
||||
<property name="file.encoding" value="UTF-8"/>
|
||||
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
|
||||
<property name="java.vendor.version" value="Homebrew"/>
|
||||
<property name="localRepository" value="/Users/maddy/.m2/repository"/>
|
||||
<property name="java.vendor.url.bug" value="https://github.com/Homebrew/homebrew-core/issues"/>
|
||||
<property name="java.io.tmpdir" value="/var/folders/1l/36214rdn79755j30lcnmgsqh0000gn/T/"/>
|
||||
<property name="java.version" value="25.0.2"/>
|
||||
<property name="user.dir" value="/Users/maddy/Projects/cygnus/matrix/cygnus-lib"/>
|
||||
<property name="os.arch" value="aarch64"/>
|
||||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
||||
<property name="native.encoding" value="UTF-8"/>
|
||||
<property name="java.library.path" value="/Users/maddy/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
|
||||
<property name="java.vm.info" value="mixed mode, sharing"/>
|
||||
<property name="stderr.encoding" value="UTF-8"/>
|
||||
<property name="java.vendor" value="Homebrew"/>
|
||||
<property name="java.vm.version" value="25.0.2"/>
|
||||
<property name="stdin.encoding" value="UTF-8"/>
|
||||
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
|
||||
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
||||
<property name="java.class.version" value="69.0"/>
|
||||
</properties>
|
||||
<testcase name="mapsHttpStatusToCanonicalError" classname="lib.models.ErrorDetailsTest" time="0.009"/>
|
||||
<testcase name="createsAReusableErrorContract" classname="lib.models.ErrorDetailsTest" time="0.008"/>
|
||||
</testsuite>
|
||||
@@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Test set: lib.models.ErrorDetailsTest
|
||||
-------------------------------------------------------------------------------
|
||||
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s -- in lib.models.ErrorDetailsTest
|
||||
BIN
cygnus-lib/target/test-classes/lib/models/ErrorDetailsTest.class
Normal file
BIN
cygnus-lib/target/test-classes/lib/models/ErrorDetailsTest.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user