<Version versionProvider="org.faktorips.maven.mavenVersionProvider"/>
FAQ
This FAQ was created by a non-developer to provide support for questions that may arise. It contains explanations of technical terms as well as solutions to problems.
In general, the following applies throughout the tutorial:
The model objects have purple icons and should always be created in "HomeModel".
The product objects have green icons and should always be created in "HomeProduct".
Java test folders (e.g. JUnit tests) should always be created in "src/test/java".
If error messages are displayed after copy-pasting a code, missing dependencies can be imported automatically with the key combination "Ctrl-Shift-O".
@since 1.0
is added to the automatically generated codes. You can’t see that in the tutorial - why?
The sample solution of this tutorial was originally created without an archetype. In the tutorial the archetype is used to create the projects. This sets the version of the project to 1.0 and defines a version provider in the ".ipsproject" file. As a result, the version is also generated in the generated code.
This can be switched off by deleting the following entry in the ".ipsproject" file:
Part 1: Modeling and Product Configuration
Hello Faktor-IPS
-
Start Faktor-IPS with a different locale (language)
Search for the file "eclipse.ini" in the eclipse installation folder. To change the language to english insert
-nl en
For german "de".
-
What is a Maven Archetype?
An archetype is a Maven project template that already contains the most important project settings. After entering a few parameters, a working project with all the necessary files will be generated. -
Archetype issues with "mvn" command
This indicates that Maven is not installed and the PATH variable that translates the mvn-command is missing. This is usually built into Eclipse but doesn’t work properly at the moment due to a bug. To solve the error, Maven has to be installed manually:-
https://maven.apache.org/download.cgi (download correct binary)
-
In Windows move the unpacked folder (apache-maven-3.8.6) to C:\Program Files\
-
Settings - System - About - Advanced System Settings - Environmental Variables
-
System Variables (second box) - Find variable "Path" and "Edit…" - New - Paste "C:\Program Files\apache-maven-3.8.6\bin" and save
-
The PATH variable for the "mvn" command is now set and will be recognized after restarting the command line. It is possible to continue with the tutorial now.
-
-
Error message: No plugin found for prefix 'archetype' in the current project and in the plugin groups (org.jenkins-ci.tools, org.glassfish.maven.plugin, org.apache.maven.plugins, org.codehaus.mojo ) available from the repositories local (C:\Users\USER\.m2\repository), nexus https://nexus.faktorzehn.de/content/groups/private → (Help 1)
The Java version is too old (usually 1.7). This can be set with the following command via the command line: "export JAVA_HOME="<path to a newer java version (eg Java 11)>". Example: "export JAVA_HOME=C:/Users/USER/eclipse/jdk-11.0.15+10"
Working with the Model and Source-code
-
Error: The version 22.6.1.rfinal_20220613-1201 of the feature org.faktorips.feature is not compatible with the version 21.6.0 required by this project. Try to migrate the project.
Migrate Faktor-IPS. Preferred Naming Scheme (in this version!): "Unified"
Runtime access to Product Information
-
What is a classloader?
The classloader loads the individual program files (classes and resources) that are needed to run the Java code. Faktor-IPS also uses it to find the product data next to the classes. -
Cast result to a class - what does that mean?
Classes can be derived from each other. HomeProduct can be a specialization of Product (functional specialization), which in turn is a specialization of ProductComponent (technical specialization). Since the repository only knows that all products are instances of this base class, we have to tell the program that we assume we know which specialization is used in this case and "cast" to it.
Instead of
ProductComponent p = repository.getProductComponent("Home Contents Compact");
we write
HomeProduct hp = (HomeProduct) repository.getProductComponent("Home Contents Compact");
and can thus also access the methods that HomeProduct defines.
Part 2: Using Tables and Formulas
Using Tables and Formulas
-
Now create two table contents for both the products HC-Optimal and HC-Compact (or, more precisely, for their basic coverage types) with the names "RateTable Optimal 2021-12" and "RateTable Compact 2021-12".
In the Model Explorer, right-click on HC-Optimal(/HC-Compact) → New… → Table content → RateTableHome → Fill in name → Finish.
Using Formulas
-
The association between HomeContract and HomeExtraCoverage should be created in HomeContract with the type "Parent to Child". Otherwise the HomeExtraCoverage can have several HomeContracts (and therefore the logic no longer works).
Part 3: Testing with Faktor-IPS
Creating a test case
First test case fails:
Can’t create instance for toc entry TocEntry(TestCase:productdata/test/PremiumComputationTest1.ipstestcase)
java.lang.reflect.InvocationTargetException
No asserts implemented in the Java class that represents the test case type.
This means that no asserts were implemented in PremiumComputationTest.java:
public void executeAsserts(IpsTestResult result) {
// begin-user-code
// TODO : Inserts the asserts to execute.
throw new RuntimeException("No asserts implemented in the Java class that represents the test case type.");
// end-user-code
}
Comment out the line. Now another error occurs: "Not implemented yet!".
In the method executeBusinessLogic() the function HomeContract.computePremium() is called. Skip to the function by clicking computePremium() and pressing F3 afterwards.
You’ll notice that the function is not implemented yet.
public void computePremium() {
// TODO implement model method.
throw new RuntimeException("Not implemented yet!");
}