All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flextrade.jfixture.behaviours.autoproperty.AutoPropertyBuilder Maven / Gradle / Ivy

Go to download

JFixture is an open source library based on the popular .NET library, AutoFixture

The newest version!
package com.flextrade.jfixture.behaviours.autoproperty;

import com.flextrade.jfixture.BehaviourCommand;
import com.flextrade.jfixture.SpecimenBuilder;
import com.flextrade.jfixture.SpecimenContext;
import com.flextrade.jfixture.specifications.Specification;

class AutoPropertyBuilder implements SpecimenBuilder {

    private final SpecimenBuilder builder;
    private final BehaviourCommand command;
    private final Specification specification;

    public AutoPropertyBuilder(SpecimenBuilder builder, BehaviourCommand command, Specification specification) {
        this.builder = builder;
        this.command = command;
        this.specification = specification;
    }

    @Override
    public Object create(Object request, SpecimenContext context) {
        Object specimen = this.builder.create(request, context);

         if(this.specification.isSatisfiedBy(request))
             command.execute(request, specimen, context);

        return specimen;
    }

    public Specification specification() {
        return this.specification;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy