Skip to content

What to expect for the future of the FixtureFactory? #115

Open
@flaviolsousa

Description

@flaviolsousa

The fixture-factory is deprecated?
I really like the tool... but it is not having upgrades.
In fact, I noticed that there has been no commit for 14 months.
Should I continue using it in my projects?

Below is a list of improvements that I propose and could help to develop.

  1. Update the source code to Java11
    mvn test its only working on Java8 and it is broke on Java11

  2. Support to local variable type inference (var) on from/gimme
    We inform the class on from method of FixtureFacture, so I imagine something like this:

  private <T> T fromExample(Class<T> clazz) {
    if (String.class.equals(clazz))
      return (T) "Test";
    if (Integer.class.equals(clazz))
      return (T) Integer.valueOf(12);
    return null;
  }

  @Test
  public void testGenerics() {
    var str = fromExample(String.class); // ### 
    System.out.println(str.substring(0, 3));
    var num = fromExample(Integer.class); // ### 
    System.out.println(num / 2);
  }

Output:

Tes
6
  1. The Processors are useful and already working on all situations. But, to simplify, if a class that implements TemplateLoader also implements the Processor interface, the execute method could be executed when generating the instances.
    Or the Rule class can have a method postConstruct that I can override (I think I prefer this option)
    Or another way would be to create a postConstruct annotation like Spring does (This I don't know how to do 😅)

  2. The "prefix-${name}" feature is greatting. But it is not possible to do this with instances of other types (non String)

  • There could be a function similar like gimmeReference (" client.adress ")`
    that returns the instance of an object in another property.
  • But the best solution, in my opinion, would be for FixtureFactory to support Function / Predicate or any other interface for anonymous functions that generate value:
new Rule() {{
  add("locator", regex("[A-Z0-9]{6}"));
  add("branchId", random(Long.class, range(1L, 100L)));
  add("code", o -> o.getBranchId().toString() + o.locator().replace("[A-Z]", ""));   // here
  add("corporateId", o -> Integer.valueOf(o.getBranchId().toString().charAt(0)));  // and here
}}
  1. It would be very useful to have a way to use the regex or random function directly from the test (outside the template) ... for primitive types there is no example of how to do it.
    I needed this to generate queryParameters and custom headers. But I didn't find any example using FixtureFacture.

  2. Phenomenal the instant("18 years ago") feature. But don't works with LocalDate and LocalDateTime.
    Ok ... it's easy to solve like with LocalDate.now().minusYears(30). But it is strange to break the execution

  3. When I do something wrong 😇, the exception thrown does not inform the attribute name, it only tells the reason.

The items are in the order I remembered ...

Congratulations for tool ... I'm putting it on all my projects (at CVC Corp), I don't see anything like what you created anywhere.

Tell me what you think about the list items. If you liked the suggestions, and will continue to support the tool, I can try to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions