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

autofixture.publicinterface.inline.strings.StringOfLengthGenerator Maven / Gradle / Ivy

package autofixture.publicinterface.inline.strings;

import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InlineInstanceGenerator;

public class StringOfLengthGenerator implements InlineInstanceGenerator {

  private final int charactersCount;

  public StringOfLengthGenerator(final int charactersCount) {
    this.charactersCount = charactersCount;
  }

  @Override
  public String next(final FixtureContract fixture) {
    final StringBuilder result = new StringBuilder();
    while (result.length() < charactersCount) {
      result.append(fixture.create(String.class));
    }
    return result.substring(0, charactersCount);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy