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

Remove JsonView filter #11189

Merged
merged 4 commits into from
Sep 18, 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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.micronaut.context.DefaultApplicationContext
import io.micronaut.context.env.MapPropertySource
import io.micronaut.context.env.PropertySource
import io.micronaut.jackson.JacksonConfiguration
import io.micronaut.jackson.databind.JacksonDatabindMapper
import spock.lang.Specification

class JsonViewSetupSpec extends Specification {
Expand All @@ -32,8 +33,7 @@ class JsonViewSetupSpec extends Specification {

expect:
applicationContext.containsBean(JacksonConfiguration)
!applicationContext.containsBean(JsonViewMediaTypeCodecFactory)
!applicationContext.containsBean(JsonViewServerFilter)
!applicationContext.getBean(JacksonDatabindMapper).@allowViews

cleanup:
applicationContext?.close()
Expand All @@ -51,8 +51,7 @@ class JsonViewSetupSpec extends Specification {

expect:
applicationContext.containsBean(JacksonConfiguration)
applicationContext.containsBean(JsonViewMediaTypeCodecFactory)
applicationContext.containsBean(JsonViewServerFilter)
applicationContext.getBean(JacksonDatabindMapper).@allowViews

cleanup:
applicationContext?.close()
Expand Down
1 change: 1 addition & 0 deletions http-server-tck/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
exclude(group = "io.micronaut")
}
annotationProcessor(projects.httpValidation)
annotationProcessor(projects.graal)

compileOnly(platform(libs.test.boms.micronaut.validation))
compileOnly(libs.micronaut.validation) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2017-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.http.server.tck.tests.jsonview;

import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpStatus;
import io.micronaut.http.tck.AssertionUtils;
import io.micronaut.http.tck.BodyAssertion;
import io.micronaut.http.tck.HttpResponseAssertion;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Map;

import static io.micronaut.http.tck.TestScenario.asserts;

@SuppressWarnings({
"java:S5960", // We're allowed assertions, as these are used in tests only
"checkstyle:MissingJavadocType",
"checkstyle:DesignForExtension"
})
class JsonViewsTest {

public static final String SPEC_NAME = "JsonViewsTest";

private static final Map<String, Object> CONFIGURATION = Map.of("jackson.json-view.enabled", true);

@Test
void testJsonViewPojo() throws Exception {
assertPath("/views/pojo");
}

@Test
void testJsonViewList() throws Exception {
assertPath("/views/list");
}

@Test
void testJsonViewOptional() throws Exception {
assertPath("/views/optional");
}

@Test
void testJsonViewMono() throws Exception {
assertPath("/views/mono");
}

@Test
void testJsonViewFlux() throws Exception {
assertPath("/views/flux");
}

@Test
void testJsonViewFuture() throws Exception {
assertPath("/views/future");
}

private void assertPath(String path) throws IOException {
asserts(SPEC_NAME,
CONFIGURATION,
HttpRequest.GET(path),
(server, request) -> AssertionUtils.assertDoesNotThrow(server, request, HttpResponseAssertion.builder()
.body(BodyAssertion.builder().body("password").doesntContain())
.status(HttpStatus.OK)
.build()));
}

}
Loading
Loading