0
I’m ultilizing the lib Fixture-Factory to create templates for my tests, but working with it, I got the following error!
Index 55663 out of bounds for length 2187
those are my models:
Cityprop: Class with generic attributes for the city.
@Data
@AllArgsConstructor
public abstract class CityProp {
private String name;
}
Citytour: Class with specific attributes for a given task, extending Cityprop
@Data
@EqualsAndHashCode(callSuper = true)
public class CityTour extends CityProp{
private Integer index;
public CityTour(String name, Integer index) {
super(name);
this.index = index;
}
}
Tourprop: Class where has all generic attributes for ride, as can be seen the attribute for Cities are in a List
@Data
public abstract class TourProp {
private Long id;
private String code;
private String name;
private LocalDate startDate;
private LocalDate endDate;
private Integer days;
private BigDecimal price;
private String currency;
private List<CityTour> cities;
private Set<String> categories;
private Integer amountCities;
private Customization customization;
private List<String> links;
private String rateToken;
}
Tour: Specific class, created to instantiate the Ride with generic attributes
public class Tour extends TourProp{
}
Already with the templates created, I also have your templates, which are to generate the class instance.
Citytourtemplateloader
public class CityTourTemplateLoader implements TemplateLoader {
@Override
public void load() {
Fixture.of(CityTour.class).addTemplate("suzuka", new Rule(){{
add("name", "suzuka");
add("index", 0);
}});
Fixture.of(CityTour.class).addTemplate("roma", new Rule(){{
add("name", "roma");
add("index", 1);
}});
Fixture.of(CityTour.class).addTemplate("paris", new Rule(){{
add("name", "paris");
add("index", 2);
}});
}
}
Tourtemplateloader
public class TourTemplateLoader implements TemplateLoader {
@Override
public void load() {
Fixture.of(Tour.class).addTemplate("complete", new Rule() {{
add("id", 1L);
add("code", "1");
add("name", "Europa Sim");
add("startDate", LocalDate.of(2019, 2, 3));
add("endDate", LocalDate.of(2019, 2, 13));
add("days", 18);
add("price", new BigDecimal(1000));
add("currency", "EUR");
add("cities", has(3).of(CityTour.class, "suzuka", "roma", "paris"));
add("categories", new HashSet<>(Collections.singletonList("Premium")));
add("amountCities", 1);
add("customization", one(Customization.class, "allTrue"));
add("links", Arrays.asList("https://image/123", "https://image/abc"));
add("rateToken", "a");
}});
}
}
When trying to run the process on this particular line:
add("cities", has(3).of(CityTour.class, "suzuka", "roma", "paris"));
The error quoted and returned.