This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 5abe93fd authored by Michael Breu's avatar Michael Breu
Browse files

Extending PropertiesTester

parent f388fadc
Branches
2 merge requests!231New Deployment into production and update gitlab,!225Resolve "Collections mehr hervorheben"
...@@ -24,7 +24,43 @@ import tech.jhipster.service.filter.StringFilter; ...@@ -24,7 +24,43 @@ import tech.jhipster.service.filter.StringFilter;
/** /**
* tests all getters and setters of a bean. * tests all getters and setters of a bean.
* If some setters should not be tested, it can be submitted in an exception
* list. It supports getters for
* <ul>
* <li>String</li>
* <li>boolean/Boolean</li>
* <li>int/Integer</li>
* <li>float/double/Float/Double</li>
* <li>byte/Byte</li>
* <li>byte[]</li>
* <li><T>[]</li>
* <li>java.sql.Timestamp</li>
* <li>java.util.Date</li>
* <li>List<T></li>
* <li>enums</li>
* <li>tech.jhipster.service.filter.{String|Boolean|Integer|LocalDate|Long}Filter</li>
*
*
* </ul>
*
* <br>
* <p>
* <b>Usage:</b>
* </p>
* <p>
*
* <pre>
* {@literal @}Test
* void testBean() {
* PropertiesTester pt = new PropertiesTester();
*
* pt.testProperties(TestBean.class, /* except * / "setDoubledString");
* }
* </pre>
* </p>
*
* @author arctis Softwaretechnologie Team * @author arctis Softwaretechnologie Team
* @see PropertiesTesterTests
* *
*/ */
@Controller @Controller
......
package at.ac.uibk.gitsearch.testingUtilities;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
class PropertiesTesterTests {
public static class TestBean {
private boolean booleanField;
private String stringField;
private int intField;
private String[] arrayField;
public boolean isBooleanField() {
return booleanField;
}
public void setBooleanField(boolean booleanField) {
this.booleanField = booleanField;
}
public String getStringField() {
return stringField;
}
public void setStringField(String stringField) {
this.stringField = stringField;
}
public int getIntField() {
return intField;
}
public void setIntField(int intField) {
this.intField = intField;
}
public String getDoubledString() {
return stringField;
}
public void setDoubledString(String doubledString) {
if (doubledString != null) {
this.stringField = doubledString + doubledString;
} else {
this.stringField = null;
}
}
public String[] getArrayField() {
return arrayField;
}
public void setArrayField(String[] arrayField) {
this.arrayField = arrayField;
}
}
@Test
void testBean() {
PropertiesTester pt = new PropertiesTester();
pt.testProperties(TestBean.class, /* except */"setDoubledString");
// extra tests for setDoubledString
TestBean tb = new TestBean();
tb.setDoubledString("abc");
assertEquals("abcabc", tb.getDoubledString());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment