openpojo

This project was born out of a need to validate all POJOs (Plain Old Java Object) are behaving correctly. This project has two main aspects to it: * Make Testing as easy as possible. * Simplifying identity management (hashCode / equals) using annotation.

License

License

GroupId

GroupId

com.openpojo
ArtifactId

ArtifactId

openpojo
Last Version

Last Version

0.9.1
Release Date

Release Date

Type

Type

jar
Description

Description

openpojo
This project was born out of a need to validate all POJOs (Plain Old Java Object) are behaving correctly. This project has two main aspects to it: * Make Testing as easy as possible. * Simplifying identity management (hashCode / equals) using annotation.
Project URL

Project URL

http://openpojo.com/
Source Code Management

Source Code Management

https://github.com/OpenPojo/openpojo

Download openpojo

How to add to project

<!-- https://jarcasting.com/artifacts/com.openpojo/openpojo/ -->
<dependency>
    <groupId>com.openpojo</groupId>
    <artifactId>openpojo</artifactId>
    <version>0.9.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.openpojo/openpojo/
implementation 'com.openpojo:openpojo:0.9.1'
// https://jarcasting.com/artifacts/com.openpojo/openpojo/
implementation ("com.openpojo:openpojo:0.9.1")
'com.openpojo:openpojo:jar:0.9.1'
<dependency org="com.openpojo" name="openpojo" rev="0.9.1">
  <artifact name="openpojo" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.openpojo', module='openpojo', version='0.9.1')
)
libraryDependencies += "com.openpojo" % "openpojo" % "0.9.1"
[com.openpojo/openpojo "0.9.1"]

Dependencies

provided (6)

Group / Artifact Type Version
log4j : log4j Optional jar 1.2.17
org.slf4j : slf4j-api Optional jar 1.7.26
org.slf4j : slf4j-log4j12 Optional jar 1.7.26
junit : junit Optional jar 4.13.1
org.testng : testng Optional jar 6.14.3
org.ow2.asm : asm Optional jar 7.1

test (1)

Group / Artifact Type Version
org.hamcrest : hamcrest-all Optional jar 1.3

Project Modules

There are no modules declared in this project.

OpenPojo Build Status Coverage Status Maven Central

POJO Testing & Identity Management Made Trivial

Maven Group Plugin Latest Version
com.openpojo.openpojo 0.9.1

Testing Example

public class PojoTest {
  // Configured for expectation, so we know when a class gets added or removed.
  private static final int EXPECTED_CLASS_COUNT = 1;

  // The package to test
  private static final String POJO_PACKAGE = "com.openpojo.sample";

  @Test
  public void ensureExpectedPojoCount() {
    List <PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE,
                                                                   new FilterPackageInfo());
    Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
  }

  @Test
  public void testPojoStructureAndBehavior() {
    Validator validator = ValidatorBuilder.create()
                            // Add Rules to validate structure for POJO_PACKAGE
                            // See com.openpojo.validation.rule.impl for more ...
                            .with(new GetterMustExistRule())
                            .with(new SetterMustExistRule())
                            // Add Testers to validate behaviour for POJO_PACKAGE
                            // See com.openpojo.validation.test.impl for more ...
                            .with(new SetterTester())
                            .with(new GetterTester())
                            .build();

    validator.validate(POJO_PACKAGE, new FilterPackageInfo());
  }
}

Identity Management Example

public class Person {
  @BusinessKey(caseSensitive = false)  //Configure your field(s)
  private String lastName;

  @Override
  public boolean equals(Object obj) {
    return BusinessIdentity.areEqual(this, obj);
  }

  @Override
  public int hashCode() {
    return BusinessIdentity.getHashCode(this);
  }

  @Override
  public String toString() {
      return BusinessIdentity.toString(this);
  }
}

For more examples and the tutorials see the Wiki

com.openpojo

OpenPojo

Java libraries to simplify inherent complexity.

Versions

Version
0.9.1
0.9.0
0.8.13
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0