Remove ThreadLocal in GraphQlArgumentBinderTests
This commit is contained in:
@@ -45,14 +45,13 @@ class GraphQlArgumentBinderTests {
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
private final ThreadLocal<GraphQlArgumentBinder> initializer =
|
||||
ThreadLocal.withInitial(() -> new GraphQlArgumentBinder(null));
|
||||
private final GraphQlArgumentBinder binder = new GraphQlArgumentBinder(null);
|
||||
|
||||
|
||||
@Test
|
||||
void defaultConstructor() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment("{\"key\":{\"name\":\"test\"}}"), "key",
|
||||
ResolvableType.forClass(SimpleBean.class));
|
||||
|
||||
@@ -63,7 +62,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void defaultConstructorWithNestedBeanProperty() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment(
|
||||
"{\"key\":{" +
|
||||
"\"name\":\"test name\"," +
|
||||
@@ -84,7 +83,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void defaultConstructorWithNestedBeanListProperty() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment("{\"key\":{\"items\":[{\"name\":\"first\"},{\"name\":\"second\"}]}}"), "key",
|
||||
ResolvableType.forClass(ItemListHolder.class));
|
||||
|
||||
@@ -96,7 +95,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test // gh-301
|
||||
void defaultConstructorWithNestedBeanListEmpty() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment("{\"key\":{\"items\": []}}"), "key",
|
||||
ResolvableType.forClass(ItemListHolder.class));
|
||||
|
||||
@@ -108,7 +107,7 @@ class GraphQlArgumentBinderTests {
|
||||
void defaultConstructorBindingError() {
|
||||
|
||||
assertThatThrownBy(
|
||||
() -> initializer.get().bind(
|
||||
() -> this.binder.bind(
|
||||
environment("{\"key\":{\"name\":\"test\",\"age\":\"invalid\"}}"), "key",
|
||||
ResolvableType.forClass(SimpleBean.class)))
|
||||
.extracting(ex -> ((BindException) ex).getFieldErrors())
|
||||
@@ -123,7 +122,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void primaryConstructor() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment("{\"key\":{\"name\":\"test\"}}"), "key",
|
||||
ResolvableType.forClass(PrimaryConstructorBean.class));
|
||||
|
||||
@@ -134,7 +133,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void primaryConstructorWithBeanArgument() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment(
|
||||
"{\"key\":{" +
|
||||
"\"item\":{\"name\":\"Item name\"}," +
|
||||
@@ -152,7 +151,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void primaryConstructorWithNestedBeanList() throws Exception {
|
||||
|
||||
Object result = initializer.get().bind(
|
||||
Object result = this.binder.bind(
|
||||
environment(
|
||||
"{\"key\":{\"items\":[" +
|
||||
"{\"name\":\"first\"}," +
|
||||
@@ -168,7 +167,7 @@ class GraphQlArgumentBinderTests {
|
||||
@Test
|
||||
void primaryConstructorNotFound() {
|
||||
assertThatThrownBy(
|
||||
() -> initializer.get().bind(
|
||||
() -> this.binder.bind(
|
||||
environment("{\"key\":{\"name\":\"test\"}}"), "key",
|
||||
ResolvableType.forClass(NoPrimaryConstructorBean.class)))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
@@ -179,7 +178,7 @@ class GraphQlArgumentBinderTests {
|
||||
void primaryConstructorBindingError() {
|
||||
|
||||
assertThatThrownBy(
|
||||
() -> initializer.get().bind(
|
||||
() -> this.binder.bind(
|
||||
environment(
|
||||
"{\"key\":{" +
|
||||
"\"name\":\"Hello\"," +
|
||||
@@ -205,7 +204,7 @@ class GraphQlArgumentBinderTests {
|
||||
void primaryConstructorBindingErrorWithNestedBeanList() {
|
||||
|
||||
assertThatThrownBy(
|
||||
() -> initializer.get().bind(
|
||||
() -> this.binder.bind(
|
||||
environment(
|
||||
"{\"key\":{\"items\":[" +
|
||||
"{\"name\":\"first\", \"age\":\"invalid\"}," +
|
||||
|
||||
Reference in New Issue
Block a user