-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
90 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
maven-central-plugin/src/test/java/org/maven/search/rest/model/SimplePojoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.maven.search.rest.model; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.openpojo.reflection.PojoClass; | ||
import com.openpojo.reflection.PojoClassFilter; | ||
import com.openpojo.reflection.filters.FilterClassName; | ||
import com.openpojo.reflection.impl.PojoClassFactory; | ||
import com.openpojo.validation.PojoValidator; | ||
import com.openpojo.validation.affirm.Affirm; | ||
import com.openpojo.validation.rule.impl.GetterMustExistRule; | ||
import com.openpojo.validation.rule.impl.NoPublicFieldsRule; | ||
import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule; | ||
import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule; | ||
import com.openpojo.validation.rule.impl.SetterMustExistRule; | ||
import com.openpojo.validation.test.impl.DefaultValuesNullTester; | ||
import com.openpojo.validation.test.impl.GetterTester; | ||
import com.openpojo.validation.test.impl.SetterTester; | ||
|
||
public class SimplePojoTest { | ||
|
||
private static final int EXPECTED_CLASS_COUNT = 5; | ||
|
||
private List<PojoClass> pojoClasses; | ||
|
||
private PojoValidator pojoValidator; | ||
|
||
@Before | ||
public void setup() { | ||
// The package to test | ||
final String packageName = Answer.class.getPackage().getName(); | ||
final PojoClassFilter filter = new FilterClassName("^((?!Test$).)*$"); | ||
this.pojoClasses = PojoClassFactory.getPojoClasses(packageName, filter); | ||
|
||
this.pojoValidator = new PojoValidator(); | ||
|
||
// Create Rules to validate structure for POJO_PACKAGE | ||
this.pojoValidator.addRule(new NoPublicFieldsRule()); | ||
this.pojoValidator.addRule(new NoStaticExceptFinalRule()); | ||
this.pojoValidator.addRule(new GetterMustExistRule()); | ||
this.pojoValidator.addRule(new SetterMustExistRule()); | ||
this.pojoValidator.addRule(new SerializableMustHaveSerialVersionUIDRule()); | ||
|
||
// Create Testers to validate behaviour for POJO_PACKAGE | ||
this.pojoValidator.addTester(new DefaultValuesNullTester()); | ||
this.pojoValidator.addTester(new SetterTester()); | ||
this.pojoValidator.addTester(new GetterTester()); | ||
} | ||
|
||
@Test | ||
public void ensureExpectedPojoCount() { | ||
Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, this.pojoClasses.size()); | ||
} | ||
|
||
@Test | ||
public void testPojoStructureAndBehavior() { | ||
for (final PojoClass pojoClass : this.pojoClasses) { | ||
this.pojoValidator.runValidation(pojoClass); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters