Giter VIP home page Giter VIP logo

Comments (6)

AlexBischof avatar AlexBischof commented on July 23, 2024

Would the following be ok?

<configuration>
  <templates>
     <template>
         <key>ABSTRACT_ASSERT_CLASS</key>
         <!-- absolute or relative path -->
         <file>whatever/template.txt</file>
     </template>
  </templates>
<!-- snip -->
</configuration>

from assertj-assertions-generator-maven-plugin.

joel-costigliola avatar joel-costigliola commented on July 23, 2024

Let's reuse slightly modified constants of BaseAssertionGenerator:

IS_ASSERTION_TEMPLATE
HAS_ELEMENTS_ASSERTION_TEMPLATE_FOR_ARRAY
HAS_ELEMENTS_ASSERTION_TEMPLATE_FOR_ITERABLE
HAS_ASSERTION_TEMPLATE
HAS_ASSERTION_TEMPLATE_FOR_PRIMITIVE
HAS_ASSERTION_TEMPLATE_FOR_REAL_NUMBER
ASSERTION_CLASS_TEMPLATE 
HIERARCHICAL_ASSERTION_CLASS_TEMPLATE
ABSTRACT_ASSERTION_CLASS_TEMPLATE
ASSERTIONS_ENTRY_POINT_CLASS_TEMPLATE
ASSERTION_ENTRY_POINT_METHOD_TEMPLATE
SOFT_ENTRY_POINT_ASSERTIONS_CLASS_TEMPLATE
JUNIT_SOFT_ENTRY_POINT_ASSERTIONS_CLASS_TEMPLATE
SOFT_ENTRY_POINT_ASSERTION_METHOD_TEMPLATE
BDD_ENTRY_POINT_ASSERTIONS_CLASS_TEMPLATE
BDD_ENTRY_POINT_ASSERTION_METHOD_TEMPLATE

I have just made this changes:

CUSTOM_ASSERTION_CLASS_TEMPLATE  -> ASSERTION_CLASS_TEMPLATE
CUSTOM_HIERARCHICAL_ASSERTION_CLASS_TEMPLATE -> HIERARCHICAL_ASSERTION_CLASS_TEMPLATE
CUSTOM_ABSTRACT_ASSERTION_CLASS_TEMPLATE -> ABSTRACT_ASSERTION_CLASS_TEMPLATE

to be consistent, let's do that renaming in BaseAssertionGenerator along with the default file names, ie:

static final String DEFAULT_CUSTOM_ASSERTION_CLASS_TEMPLATE = "custom_assertion_class_template.txt";
static final String DEFAULT_CUSTOM_HIERARCHICAL_ASSERTION_CLASS_TEMPLATE = "custom_hierarchical_assertion_class_template.txt";
static final String DEFAULT_CUSTOM_ABSTRACT_ASSERTION_CLASS_TEMPLATE = "custom_abstract_assertion_class_template.txt";

should be

static final String DEFAULT_ASSERTION_CLASS_TEMPLATE = "assertion_class_template.txt";
static final String DEFAULT_HIERARCHICAL_ASSERTION_CLASS_TEMPLATE = "hierarchical_assertion_class_template.txt";
static final String DEFAULT_ABSTRACT_ASSERTION_CLASS_TEMPLATE = "abstract_assertion_class_template.txt";

from assertj-assertions-generator-maven-plugin.

AlexBischof avatar AlexBischof commented on July 23, 2024

I like the renaming.
What do you think of my proposal above for the pom.xml?

from assertj-assertions-generator-maven-plugin.

AlexBischof avatar AlexBischof commented on July 23, 2024

Oh, i have to use the Mojo parameter type Map therefore the resulting structure would be

<configuration>
  <templates>
      <IS_ASSERTION_TEMPLATE>whatever/template.txt</IS_ASSERTION_TEMPLATE>
  </templates>
<!-- snip -->
</configuration>

from assertj-assertions-generator-maven-plugin.

joel-costigliola avatar joel-costigliola commented on July 23, 2024

I prefer your latest suggestion but everything lowercase

<configuration>
  <templates>
      <is_assertion_template>whatever/template.txt</is_assertion_template>
  </templates>
<!-- snip -->
</configuration>

from assertj-assertions-generator-maven-plugin.

AlexBischof avatar AlexBischof commented on July 23, 2024

My first proposal for that issue is ready but it lacks in two things which is open for discussion:

  • It was not possible for me to use the Template(Type, File) constructor because it always results in an NPE when i had used the plugin in a test project. I couldn't figure out why it is thrown. So the template file reading is now part of the maven plugin generator which i consider as a workaround
  • My test project contains the following snippet which leads to a lot of writing considering the directory when somebody has more then one template . This can be simplified by introducing another parameter templateDir which would be used if the path is a relative one.
<templates>
   <has_for_primitive>target/classes/custom_has_assertion_template_for_primitive.txt</has_for_primitive>
</templates>

You wrote you have made changes. Where can i found them?

from assertj-assertions-generator-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.