Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build #2548

Merged
merged 8 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/templates.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ asciidoctor-gradle-jvm = "3.3.2"
asciidoctor-maven-plugin = "2.2.6"
asciidoctorj = "2.5.13"
asciidoctorj-diagram = "2.2.13"
awaitility = "4.2.1"
awaitility = "4.2.2"
azure-functions-gradle-plugin = "1.15.0"
azure-functions-maven-plugin = "1.36.0"
bom-opentelemetry = "1.14.0-alpha"
Expand Down Expand Up @@ -68,7 +68,7 @@ ktor = "2.3.11"
jakarta-validation-api = "3.0.2"
spring-boot-gradle-plugin = "3.3.0"
spring-dependency-management-plugin = "1.1.6"
micronaut-starter-aws-cdk = "4.3.7"
micronaut-starter-aws-cdk = "4.5.1"
spring-boot-starter-parent="3.3.0"
graaljs = "24.0.2" # Once this is bumped past 24.1, you should be able to remove the disabling of Loom in the config properties in the React feature.
frontend-maven-plugin = "1.15.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -93,7 +91,7 @@ public DiffController(ProjectGenerator projectGenerator, FeatureDiffer featureDi
@ApiResponse(responseCode = "404", description = "If no difference is found")
@ApiResponse(responseCode = "400", description = "If the supplied parameters are invalid")
@ApiResponse(responseCode = "200", description = "A textual diff", content = @Content(mediaType = "text/plain"))
public Publisher<String> diffFeature(
public String diffFeature(
@NotNull ApplicationType type,
@Nullable String name,
@NonNull @NotBlank String feature,
Expand Down Expand Up @@ -127,7 +125,7 @@ public Publisher<String> diffFeature(
throw new HttpStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}

return diffFlowable(projectGenerator, generatorContext);
return diff(projectGenerator, generatorContext);
}

/**
Expand All @@ -146,7 +144,7 @@ public Publisher<String> diffFeature(
@ApiResponse(responseCode = "404", description = "If no difference is found")
@ApiResponse(responseCode = "400", description = "If the supplied parameters are invalid")
@ApiResponse(responseCode = "200", description = "A textual diff", content = @Content(mediaType = "text/plain"))
public Publisher<String> diffApp(
public String diffApp(
ApplicationType type,
@Pattern(regexp = "[\\w\\d-_\\.]+") String name,
@Nullable List<String> features,
Expand Down Expand Up @@ -179,49 +177,45 @@ public Publisher<String> diffApp(
throw new HttpStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}

return diffFlowable(projectGenerator, generatorContext);
return diff(projectGenerator, generatorContext);
}

private Publisher<String> diffFlowable(ProjectGenerator projectGenerator, GeneratorContext generatorContext) {
return Flux.create(emitter -> {
try {
// empty string so there is at least some content
// if there is no difference
emitter.next("");
featureDiffer.produceDiff(
projectGenerator,
generatorContext,
new ConsoleOutput() {
@Override
public void out(String message) {
emitter.next(message + LINE_SEPARATOR);
}
private String diff(ProjectGenerator projectGenerator, GeneratorContext generatorContext) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yawkat @dstepanov have we changed how Publisher<String> is managed? I had to change this. The previous code was timing out in the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final StringBuilder sb = new StringBuilder();
try {
featureDiffer.produceDiff(
projectGenerator,
generatorContext,
new ConsoleOutput() {
@Override
public void out(String message) {
sb.append(message).append(LINE_SEPARATOR);
}

@Override
public void err(String message) {
// will never be called
}
@Override
public void err(String message) {
// will never be called
}

@Override
public void warning(String message) {
// will never be called
}
@Override
public void warning(String message) {
// will never be called
}

@Override
public boolean showStacktrace() {
return false;
}
@Override
public boolean showStacktrace() {
return false;
}

@Override
public boolean verbose() {
return false;
}
@Override
public boolean verbose() {
return false;
}
);
emitter.complete();
} catch (Exception e) {
emitter.error(new HttpStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Could not produce diff: " + e.getMessage()));
}
});
}
);
return sb.toString();
} catch (Exception e) {
throw new HttpStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Could not produce diff: " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface DiffOperations {
* @param requestInfo The request info
* @return An HTTP response that emits a writable
*/
Publisher<String> diffFeature(
String diffFeature(
@NotNull ApplicationType type,
@Nullable String name,
@NotBlank @NonNull String feature,
Expand All @@ -70,7 +70,7 @@ Publisher<String> diffFeature(
* @param requestInfo The request info
* @return An HTTP response that emits a writable
*/
Publisher<String> diffApp(
String diffApp(
ApplicationType type,
String name,
@Nullable List<String> features,
Expand Down
4 changes: 2 additions & 2 deletions starter-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

ext {
picocliVersion = '4.7.6'
picocliVersion = '4.7.5'
}

configurations {
Expand Down Expand Up @@ -34,7 +34,7 @@ dependencies {
implementation("javax.inject:javax.inject:1")
implementation("org.shredzone.acme4j:acme4j-client")
implementation("org.shredzone.acme4j:acme4j-utils:2.16")
implementation("org.jline:jline:3.19.0")
implementation('org.jline:jline:3.19.0')

testImplementation("io.micronaut.picocli:micronaut-picocli")
testImplementation("org.testcontainers:spock")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.micronaut.http.client.annotation.Client
import io.micronaut.runtime.server.EmbeddedServer
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.inject.Inject
import spock.lang.Ignore
import spock.lang.Specification

@MicronautTest
Expand All @@ -20,41 +21,57 @@ class OpenAPISpec extends Specification {

void "test swagger-ui"() {
when:
def response = server.getURI().resolve("/swagger-ui").toURL().text
String response = server.getURI().resolve("/swagger-ui").toURL().text

List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
matches.size()
yml

and:
server.getURI().resolve(yml).toURL().text.contains("title: Micronaut Launch")
}

@Ignore("swagger-ui output have changed")
void "test swagger-ui links"() {
when:
String response = server.getURI().resolve("/swagger-ui").toURL().text
List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }

then:
matches.size()


and:
matches.each {
assert client.toBlocking().exchange(it).status() == HttpStatus.OK
}
}

void "test rapidoc"() {
@Ignore("rapidoc output have changed")
void "test rapidoc links"() {
when:
def response = server.getURI().resolve("/rapidoc").toURL().text

String response = server.getURI().resolve("/rapidoc").toURL().text
List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
matches.size()
yml

and:
server.getURI().resolve(yml).toURL().text.contains("title: Micronaut Launch")

and:
matches.each {
assert client.toBlocking().exchange(it).status() == HttpStatus.OK
}
}

void "test rapidoc"() {
when:
String response = server.getURI().resolve("/rapidoc").toURL().text
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
yml

and:
server.getURI().resolve(yml).toURL().text.contains("title: Micronaut Launch")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.micronaut.http.client.annotation.Client
import io.micronaut.runtime.server.EmbeddedServer
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.inject.Inject
import spock.lang.Ignore
import spock.lang.Specification

@MicronautTest
Expand All @@ -18,19 +19,42 @@ class OpenAPISpec extends Specification {
@Inject
HttpClient client

void "test swagger-ui"() {
@Ignore
void "test swagger-ui links"() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@altro3 has the html output changed for swagger-ui and rapid? These tests which verified the links fail now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, links were changed. Chanes here: micronaut-projects/micronaut-openapi#1626

Currently, links to scripts are not explicitly specified, and scripts are loaded dynamically. The code in the test must be changed

when:
def response = client.toBlocking().retrieve("/swagger-ui/index.html", String)

String response = client.toBlocking().retrieve("/swagger-ui/index.html", String)
List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
matches.size()

and:
matches.each {
assert client.toBlocking().exchange(it).status() == HttpStatus.OK
}
}

void "test swagger-ui"() {
when:
String response = client.toBlocking().retrieve("/swagger-ui/index.html", String)
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
yml

and:
server.getURI().resolve(yml).toURL().text.contains("title: Micronaut Launch")
}

@Ignore
void "test rapidoc links"() {
when:
String response = client.toBlocking().retrieve("/rapidoc/index.html", String)

List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }

then:
matches.size()

and:
matches.each {
Expand All @@ -40,21 +64,14 @@ class OpenAPISpec extends Specification {

void "test rapidoc"() {
when:
def response = client.toBlocking().retrieve("/rapidoc/index.html", String)
String response = client.toBlocking().retrieve("/rapidoc/index.html", String)

List<String> matches = (response =~ /(?:src|href)=['"]([^'"]+)['"]/).collect { it[1] as String }
String yml = (response =~ /['"]([^'"]+\.yml)['"]/)[0][1]

then:
matches.size()
yml

and:
server.getURI().resolve(yml).toURL().text.contains("title: Micronaut Launch")

and:
matches.each {
assert client.toBlocking().exchange(it).status() == HttpStatus.OK
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class MicrometerSpec extends CommandSpec {
output?.contains("BUILD SUCCESS")

where:
language << Language.values()
language << Language.values().findAll { it != Language.GROOVY }

}

void "test #buildTool micrometer-cloudwatch with #language"(BuildTool buildTool, Language language) {
Expand Down
Loading