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

autofixture.generators.UrlGenerator Maven / Gradle / Ivy

There is a newer version: 2.1.10
Show newest version
package autofixture.generators;

import autofixture.exceptions.ObjectCreationException;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceGenerator;
import autofixture.interfaces.InstanceType;

import java.net.MalformedURLException;
import java.net.URL;

public class UrlGenerator implements InstanceGenerator {

  @Override
  public  boolean appliesTo(final InstanceType instanceType) {
    return instanceType.isRawTypeAssignableFrom(URL.class);
  }

  @SuppressWarnings("unchecked")
  @Override
  public  T next(final InstanceType instanceType, final FixtureContract fixture) {
    try {
      return (T) new URL("https://github.com/grzesiek-galezowski/jfixture/" + fixture.create(int.class));
    } catch (final MalformedURLException e) {
      throw new ObjectCreationException(instanceType, e);
    }
  }

  @Override
  public void setOmittingAutoProperties(final boolean isOn) {
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy