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

Add generating a circular-reference object #519

Merged
merged 1 commit into from
Dec 10, 2022

Conversation

seongahjo
Copy link
Contributor

@seongahjo seongahjo commented Nov 30, 2022

Summary

Add generating a circular-reference object

(Optional): Description

순환참조일 경우 1-depth까지만 생성합니다.

For example,

class A {
   B b;
}

class B {
   A a;
}

A a = fixture.giveMeOne(A.class);
{
    "b" :  {
        "a" : {
            "b" : null
        }
   }
}

How Has This Been Tested?

  • sampleSelfRecursiveObject
  • sampleSelfRecursiveList
  • sampleRecursiveObject

resolves #495

@esfomeado
Copy link
Contributor

Is there any ETA of when this will be released?

@seongahjo seongahjo merged commit 5e240d1 into main Dec 10, 2022
@seongahjo seongahjo deleted the sa/not-recursive-traverse branch December 10, 2022 08:14
@seongahjo
Copy link
Contributor Author

@esfomeado
0.4.9 is available now!

@esfomeado
Copy link
Contributor

esfomeado commented Dec 10, 2022

@seongahjo Thank you. You're a hero.

@lfcazambuja
Copy link

Hi, should this implementation work with fixture.giveMeBuilder(A.class)?

@seongahjo
Copy link
Contributor Author

@lfcazambuja
Yes, are there any issues??

@lfcazambuja
Copy link

@seongahjo Maybe. I have a situation here, but I need more time to test and check if I'm not making some mistake.

@lfcazambuja
Copy link

lfcazambuja commented Feb 10, 2023

@seongahjo I've got some time to go back to the scenario I mentioned last december, and I have an issue:

My starting point is the test provided here:

if I change this piece of code

LabMonkey sut = LabMonkey.labMonkeyBuilder().defaultNotNull(true).build();

RecursiveLeftObject actual = sut.giveMeOne(RecursiveLeftObject.class);

into this one (which I was using last december)

RecursiveLeftObject actual = MonkeyUtils.monkey().giveMeOne(RecursiveLeftObject.class);

the StackOverflowException is raised. The same occurs if I use the giveMeBuilder method.
I'm using the FixtureMonkey version 0.4.13.

My MonkeyUtils.monkey():

    public static FixtureMonkey monkey() {
        return FixtureMonkey.builder()
                .defaultGenerator(FieldReflectionArbitraryGenerator.INSTANCE)
                .nullInject(0)
                .build();
    }

Should I stop using FixtureMonkey.builder() and start using LabMonkey.labMonkeyBuilder()?

What is your recommendation?

Thanks in advance.

@esfomeado
Copy link
Contributor

@lfcazambuja Try with 0.4.11 as I have found some issues on the latest versions as well.

@seongahjo
Copy link
Contributor Author

seongahjo commented Feb 13, 2023

@lfcazambuja
Yes, a FixtureMonkey instance only supports features in 0.3 in 0.4.x.
You should use a LabMonkey

monkey() should be like below.

  public static FixtureMonkey monkey() {
        return FixtureMonkey.labMonkeyBuilder()
                .objectIntrospector(FieldReflectionArbitraryIntrospector.INSTANCE)
                .defaultNotNull(true)
                .build();
   }

Since 0.5, a LabMonkey instance would be default FixtureMonkey instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StackOverflowError
4 participants