Welcome to the Design Tests!
This project contains experiments with design tests using DesignWizard API. This project contains scripts and programs for running design tests for a set of projects that use Hibernate/JPA and it been selected from GitHub.com.
Details from Experiments
This project contains source code and R scripts for an experiment about design tests. In the experiment we used the DesignWizard API to write the design rules and to test of a set of projects. The set of projects was selected from the online repository hosted on GitHub. We selected two sample projects that should use JPA / Hibernate:
- Random sample
- 40 projects
- 145 persistant classes
- Starred sample
- 31 projects
- 108 persistant classes
So, we wrote design tests for domain model rules (design rules for persistent classes) that are described on documentation of the Hibernate Framework (See in https://docs.jboss.org/hibernate/orm/5.0/userGuide/en-US/html/ch02.html) and on the JPA Specification.
It is important to highlight some informations in the documentation about persistent classes definition:
It says that Hibernate works best if the classes of the domain model follows the conventions of Plain Old Java Object (POJO), which is also known as JavaBeans programming model.
It says that these rules are not "tough demands". So, the Hibernate does not require much of your persistent objects. However, if portability with JPA is required, the rules should be regarded as strict requirements.
For example, we wrote a design rule that checks if the entity (persistent class annotated with @Entity) implements the equals/hashCode, described in the subsection 2.1.5 of the documentation, and if these methods access the identifier property (annotated with @id). So, the execution of the rule returns true or false. Verification of design rules has been applied in two samples from github projects. We found the following results to verify the design rules.
Random sample of github projects (40 projects with 145 persistent classes)
rules | total of tests | failed tests | failed proportions |
---|---|---|---|
HashCodeAndEqualsNotUseIdentifierRule | 145 | 132 | 0.91034483 |
HashCodeAndEqualsRule | 145 | 96 | 0.66206897 |
ImplementsSerializableRule | 145 | 95 | 0.65517241 |
NoArgumentConstructorRule | 145 | 0 | 0.00000000 |
NoFinalClassRule | 145 | 0 | 0.00000000 |
ProvideGetsSetsFieldsRule | 145 | 37 | 0.25517241 |
ProvideIdentifierPropertyRule | 145 | 7 | 0.04827586 |
UseSetCollectionRule | 145 | 30 | 0.20689655 |
Starred sample of github projects (31 projects with 108 persistent classes)
rules | total of tests | failed tests | failed proportions |
---|---|---|---|
HashCodeAndEqualsNotUseIdentifierRule | 108 | 86 | 0.7962963 |
HashCodeAndEqualsRule | 108 | 78 | 0.7222222 |
ImplementsSerializableRule | 108 | 70 | 0.6481481 |
NoArgumentConstructorRule | 108 | 0 | 0.00000000 |
NoFinalClassRule | 108 | 0 | 0.00000000 |
ProvideGetsSetsFieldsRule | 108 | 34 | 0.3148148 |
ProvideIdentifierPropertyRule | 108 | 13 | 0.1203704 |
UseSetCollectionRule | 108 | 11 | 0.1018519 |
Violations of the design rules can cause functionality anomalies in the use of persistent classes. Some of these anomalies can occur in the generation of the proxy runtime; the non-use of wrapper classes; the proxies for lazy loading (performance issues); the inscription of persistent classes in a set; the reconnection of detached instances; in passing by value of persistent classes and representation of multivalued associations.
Instructions to Eclipse users
This project is deployed as an Eclipse project with Maven. In order to import DesignTests properly, consider the following steps:
- Clone the project from the official GitHub repository
- On Eclipse, install Git.
- On Eclipse, install Maven.
- On Eclipse, import a Java project of the cloned folder. Eclipse will understand the configuration on the existing project.
Instructions to Maven users
This project needs the DesignWizard dependency. The DesignWizard project has the ASM dependency considered optional in the your pom .xml file. So, to use the DesignWizard API is necessary to inform the following dependencies:
<dependency>
<groupId>org.designwizard</groupId>
<artifactId>designwizard</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>