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

Issue when calling repeat() after using index() #39

Open
Misha1Shevchuk opened this issue Jul 29, 2024 · 0 comments
Open

Issue when calling repeat() after using index() #39

Misha1Shevchuk opened this issue Jul 29, 2024 · 0 comments

Comments

@Misha1Shevchuk
Copy link

Misha1Shevchuk commented Jul 29, 2024

To reuse common field values we often use EntityBuilder, for example

`@IsTest
private class AtkBugTest {

@IsTest
private static void test1() {
    ATK.SaveResult atkResult = ATK.prepare(Opportunity.SObjectType, 10)
        .build(new OpportunityEntityBuilder())
        .field(Opportunity.Name).repeat('Test Name')
        .mock();

    List<Opportunity> opportunities = (List<Opportunity>) atkResult.get(Opportunity.SObjectType);
    for (Opportunity opp : opportunities) {
        Assert.areEqual('Test Name', opp.Name); // this fails, actual result is OPPORTUNITY-NAME-1
    }
}

public class OpportunityEntityBuilder implements ATK.EntityBuilder {

    public void build(ATK.Entity entity, Integer size) {
        entity
            .field(Opportunity.Name).index('OPPORTUNITY-NAME-{0}')
            .field(Opportunity.Description).repeat('Test Description')
            .field(Opportunity.CloseDate).repeat(Date.today().addMonths(1));
    }
}

}`

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

No branches or pull requests

1 participant