diff --git a/zuul-gateway/src/main/java/com/xtrmetl/gateway/ZuulGatewayApplication.java b/zuul-gateway/src/main/java/com/xtrmetl/gateway/ZuulGatewayApplication.java index f23d5d44..354ad234 100644 --- a/zuul-gateway/src/main/java/com/xtrmetl/gateway/ZuulGatewayApplication.java +++ b/zuul-gateway/src/main/java/com/xtrmetl/gateway/ZuulGatewayApplication.java @@ -4,9 +4,18 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +/** + * Starts the standalone mightyETL gateway with service discovery during gateway bootstrap. + */ @SpringBootApplication @EnableDiscoveryClient public class ZuulGatewayApplication { + + /** + * Launches the gateway through Spring Boot. + * + * @param args command-line arguments passed to Spring Boot + */ public static void main(String[] args) { SpringApplication.run(ZuulGatewayApplication.class, args); } diff --git a/zuul-gateway/src/test/java/com/xtrmetl/gateway/ZuulGatewayApplicationContractTest.java b/zuul-gateway/src/test/java/com/xtrmetl/gateway/ZuulGatewayApplicationContractTest.java new file mode 100644 index 00000000..f2252ee2 --- /dev/null +++ b/zuul-gateway/src/test/java/com/xtrmetl/gateway/ZuulGatewayApplicationContractTest.java @@ -0,0 +1,48 @@ +package com.xtrmetl.gateway; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Verifies the standalone gateway bootstrap contract and its beginner-readable public documentation. + */ +class ZuulGatewayApplicationContractTest { + + @Test + void bootstrapClassKeepsTheRequiredGatewayAnnotations() { + assertNotNull(ZuulGatewayApplication.class.getAnnotation(SpringBootApplication.class)); + assertNotNull(ZuulGatewayApplication.class.getAnnotation(EnableDiscoveryClient.class)); + } + + @Test + void mainEntryPointRemainsPublicStatic() throws NoSuchMethodException { + Method main = ZuulGatewayApplication.class.getDeclaredMethod("main", String[].class); + + assertTrue(Modifier.isPublic(main.getModifiers())); + assertTrue(Modifier.isStatic(main.getModifiers())); + } + + @Test + void publicBootstrapApiHasBeginnerReadableJavadoc() throws IOException { + String source = Files.readString( + Path.of("src/main/java/com/xtrmetl/gateway/ZuulGatewayApplication.java"), + StandardCharsets.UTF_8 + ); + + assertTrue(source.contains("Starts the standalone mightyETL gateway")); + assertTrue(source.contains("service discovery during gateway bootstrap")); + assertTrue(source.contains("Launches the gateway through Spring Boot")); + assertTrue(source.contains("@param args command-line arguments passed to Spring Boot")); + } +}