-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix creating arrays for constructor arguments
- Loading branch information
Tobias Knell
committed
Feb 20, 2024
1 parent
8f7c3c1
commit 7f9e09d
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/test/java/org/synyx/beanfiller/ConstructorCreationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.synyx.beanfiller; | ||
|
||
import org.junit.Test; | ||
import org.synyx.beanfiller.exceptions.FillingException; | ||
import org.synyx.beanfiller.testobjects.TestEnum; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class ConstructorCreationTest { | ||
|
||
|
||
@Test | ||
public void createsObjectViaConstructor() throws FillingException { | ||
|
||
TestObjectWithConstructor object = new BeanFiller().fillBean(TestObjectWithConstructor.class); | ||
|
||
assertThat(object.array, notNullValue()); | ||
assertThat(object.array.length, greaterThan(0)); | ||
assertThat(object.testEnum, notNullValue()); | ||
assertThat(object.innerObject, notNullValue()); | ||
assertThat(object.innerObject.foo, notNullValue()); | ||
} | ||
|
||
public static class TestObjectWithConstructor{ | ||
|
||
private final String[] array; | ||
private final TestEnum testEnum; | ||
private final InnerObject innerObject; | ||
|
||
TestObjectWithConstructor(String[] array, TestEnum testEnum, InnerObject innerObject){ | ||
|
||
this.array = array; | ||
this.testEnum = testEnum; | ||
this.innerObject = innerObject; | ||
} | ||
|
||
public String[] getArray() { | ||
return array; | ||
} | ||
|
||
public TestEnum getTestEnum() { | ||
return testEnum; | ||
} | ||
|
||
public InnerObject getInnerObject() { | ||
return innerObject; | ||
} | ||
} | ||
|
||
public static class InnerObject{ | ||
|
||
private final String foo; | ||
|
||
public InnerObject(String foo) { | ||
this.foo = foo; | ||
} | ||
|
||
public String getFoo() { | ||
return foo; | ||
} | ||
} | ||
} |