Address JavaFormat Violations in Odm Tests
Issue gh-743
This commit is contained in:
@@ -33,6 +33,7 @@ dependencies {
|
||||
testImplementation "org.apache.directory.server:apacheds-protocol-shared"
|
||||
testImplementation "org.apache.directory.server:apacheds-server-jndi"
|
||||
testImplementation "org.apache.directory.shared:shared-ldap"
|
||||
testImplementation "org.assertj:assertj-core"
|
||||
testImplementation platform('org.junit:junit-bom')
|
||||
testImplementation "org.junit.vintage:junit-vintage-engine"
|
||||
}
|
||||
@@ -28,36 +28,12 @@ import org.springframework.ldap.odm.typeconversion.ConverterManager;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.Converter;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.ConverterManagerFactoryBean;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConverterFactoryTests {
|
||||
|
||||
private static class NullConverter implements Converter {
|
||||
|
||||
public <T> T convert(Object source, Class<T> toClass) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final Converter nullConverter = new NullConverter();
|
||||
|
||||
private static class ConverterConfigTestData {
|
||||
|
||||
private Class<?>[] fromClasses;
|
||||
|
||||
private String syntax;
|
||||
|
||||
private Class<?>[] toClasses;
|
||||
|
||||
private ConverterConfigTestData(Class<?>[] fromClasses, String syntax, Class<?>[] toClasses) {
|
||||
this.fromClasses = fromClasses;
|
||||
this.syntax = syntax;
|
||||
this.toClasses = toClasses;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ConverterConfigTestData[] converterConfigTestData = new ConverterConfigTestData[] {
|
||||
new ConverterConfigTestData(new Class<?>[] { String.class }, "", new Class<?>[] { Integer.class }),
|
||||
new ConverterConfigTestData(new Class<?>[] { Byte.class, java.lang.Integer.class }, "",
|
||||
@@ -65,25 +41,6 @@ public class ConverterFactoryTests {
|
||||
new ConverterConfigTestData(new Class<?>[] { String.class }, "123",
|
||||
new Class<?>[] { java.net.URI.class }), };
|
||||
|
||||
private static class ConverterTestData {
|
||||
|
||||
private final Class<?> fromClass;
|
||||
|
||||
private final String syntax;
|
||||
|
||||
private final Class<?> toClass;
|
||||
|
||||
private final boolean canConvert;
|
||||
|
||||
private ConverterTestData(Class<?> fromClass, String syntax, Class<?> toClass, boolean canConvert) {
|
||||
this.fromClass = fromClass;
|
||||
this.syntax = syntax;
|
||||
this.toClass = toClass;
|
||||
this.canConvert = canConvert;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ConverterTestData[] converterTestData = new ConverterTestData[] {
|
||||
new ConverterTestData(java.lang.String.class, "", java.lang.Integer.class, true),
|
||||
new ConverterTestData(java.lang.Byte.class, "", java.lang.Long.class, true),
|
||||
@@ -109,10 +66,53 @@ public class ConverterFactoryTests {
|
||||
|
||||
new ExecuteRunnable<ConverterTestData>().runTests(new RunnableTests<ConverterTestData>() {
|
||||
public void runTest(ConverterTestData testData) {
|
||||
assertEquals(testData.canConvert,
|
||||
converterManager.canConvert(testData.fromClass, testData.syntax, testData.toClass));
|
||||
assertThat(testData.canConvert)
|
||||
.isEqualTo(converterManager.canConvert(testData.fromClass, testData.syntax, testData.toClass));
|
||||
}
|
||||
}, this.converterTestData);
|
||||
}
|
||||
|
||||
private static class NullConverter implements Converter {
|
||||
|
||||
public <T> T convert(Object source, Class<T> toClass) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConverterConfigTestData {
|
||||
|
||||
private Class<?>[] fromClasses;
|
||||
|
||||
private String syntax;
|
||||
|
||||
private Class<?>[] toClasses;
|
||||
|
||||
private ConverterConfigTestData(Class<?>[] fromClasses, String syntax, Class<?>[] toClasses) {
|
||||
this.fromClasses = fromClasses;
|
||||
this.syntax = syntax;
|
||||
this.toClasses = toClasses;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConverterTestData {
|
||||
|
||||
private final Class<?> fromClass;
|
||||
|
||||
private final String syntax;
|
||||
|
||||
private final Class<?> toClass;
|
||||
|
||||
private final boolean canConvert;
|
||||
|
||||
private ConverterTestData(Class<?> fromClass, String syntax, Class<?> toClass, boolean canConvert) {
|
||||
this.fromClass = fromClass;
|
||||
this.syntax = syntax;
|
||||
this.toClass = toClass;
|
||||
this.canConvert = canConvert;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.ldap.odm.typeconversion.impl.ConverterManagerImpl;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.converters.FromStringConverter;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.converters.ToStringConverter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public final class ConverterManagerTests {
|
||||
|
||||
@@ -69,35 +69,6 @@ public final class ConverterManagerTests {
|
||||
this.converterManager = null;
|
||||
}
|
||||
|
||||
private static class ConverterTestData<T> {
|
||||
|
||||
public final Class<T> destClass;
|
||||
|
||||
public final Object sourceData;
|
||||
|
||||
public final T expectedValue;
|
||||
|
||||
public final String syntax;
|
||||
|
||||
public ConverterTestData(Object sourceData, Class<T> destClass, T expectedValue) {
|
||||
this(sourceData, "", destClass, expectedValue);
|
||||
}
|
||||
|
||||
public ConverterTestData(Object sourceData, String syntax, Class<T> destClass, T expectedValue) {
|
||||
this.destClass = destClass;
|
||||
this.sourceData = sourceData;
|
||||
this.expectedValue = expectedValue;
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("sourceData=%1$s | syntax=%2$s | destClass=%3$s | expectedValue=%4$s", this.sourceData,
|
||||
this.syntax, this.destClass, this.expectedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Class to Class conversion without any syntaxes
|
||||
@Test
|
||||
public void basicTypeConverion() throws Exception {
|
||||
@@ -130,12 +101,86 @@ public final class ConverterManagerTests {
|
||||
|
||||
new ExecuteRunnable<ConverterTestData<?>>().runTests(new RunnableTests<ConverterTestData<?>>() {
|
||||
public void runTest(ConverterTestData<?> testData) {
|
||||
assertEquals(testData.expectedValue, ConverterManagerTests.this.converterManager
|
||||
assertThat(testData.expectedValue).isEqualTo(ConverterManagerTests.this.converterManager
|
||||
.convert(testData.sourceData, "", testData.destClass));
|
||||
}
|
||||
}, primitiveTypeTests);
|
||||
}
|
||||
|
||||
// Tests using syntaxes for "finer grained" mapping
|
||||
@Test
|
||||
public void syntaxBasedConversion() throws Exception {
|
||||
Converter squaredConverter = new SquaredConverter();
|
||||
this.converterManager.addConverter(String.class, "1", Integer.class, squaredConverter);
|
||||
this.converterManager.addConverter(Integer.class, "1", Integer.class, squaredConverter);
|
||||
Converter cubedConverter = new CubedConverter();
|
||||
this.converterManager.addConverter(String.class, "2", Integer.class, cubedConverter);
|
||||
this.converterManager.addConverter(Integer.class, "3", Integer.class, cubedConverter);
|
||||
|
||||
final ConverterTestData<?>[] syntaxTests = new ConverterTestData<?>[] {
|
||||
new ConverterTestData<Integer>("3", "", Integer.class, Integer.valueOf(3)),
|
||||
new ConverterTestData<Integer>("4", "", Integer.class, Integer.valueOf(4)),
|
||||
new ConverterTestData<Integer>(5, "", Integer.class, Integer.valueOf(5)),
|
||||
new ConverterTestData<Integer>(6, "", Integer.class, Integer.valueOf(6)),
|
||||
new ConverterTestData<Integer>("3", "1", Integer.class, Integer.valueOf(9)),
|
||||
new ConverterTestData<Integer>("4", "1", Integer.class, Integer.valueOf(16)),
|
||||
new ConverterTestData<Integer>(5, "1", Integer.class, Integer.valueOf(25)),
|
||||
new ConverterTestData<Integer>(6, "1", Integer.class, Integer.valueOf(36)),
|
||||
new ConverterTestData<Integer>("3", "2", Integer.class, Integer.valueOf(27)),
|
||||
new ConverterTestData<Integer>("4", "2", Integer.class, Integer.valueOf(64)),
|
||||
new ConverterTestData<Integer>(5, "3", Integer.class, Integer.valueOf(125)),
|
||||
new ConverterTestData<Integer>(6, "3", Integer.class, Integer.valueOf(216)), };
|
||||
|
||||
new ExecuteRunnable<ConverterTestData<?>>().runTests(new RunnableTests<ConverterTestData<?>>() {
|
||||
public void runTest(ConverterTestData<?> testData) {
|
||||
assertThat(testData.expectedValue).isEqualTo(ConverterManagerTests.this.converterManager
|
||||
.convert(testData.sourceData, testData.syntax, testData.destClass));
|
||||
}
|
||||
}, syntaxTests);
|
||||
|
||||
}
|
||||
|
||||
// No converter for classes
|
||||
@Test(expected = ConverterException.class)
|
||||
public void noClassConverter() throws Exception {
|
||||
this.converterManager.convert(BitSet.class, "", Integer.class);
|
||||
}
|
||||
|
||||
// Invalid syntax so converter fails
|
||||
@Test(expected = ConverterException.class)
|
||||
public void invalidSyntax() throws Exception {
|
||||
this.converterManager.convert(String.class, "not a uri", URI.class);
|
||||
}
|
||||
|
||||
private static class ConverterTestData<T> {
|
||||
|
||||
public final Class<T> destClass;
|
||||
|
||||
public final Object sourceData;
|
||||
|
||||
public final T expectedValue;
|
||||
|
||||
public final String syntax;
|
||||
|
||||
public ConverterTestData(Object sourceData, Class<T> destClass, T expectedValue) {
|
||||
this(sourceData, "", destClass, expectedValue);
|
||||
}
|
||||
|
||||
public ConverterTestData(Object sourceData, String syntax, Class<T> destClass, T expectedValue) {
|
||||
this.destClass = destClass;
|
||||
this.sourceData = sourceData;
|
||||
this.expectedValue = expectedValue;
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("sourceData=%1$s | syntax=%2$s | destClass=%3$s | expectedValue=%4$s", this.sourceData,
|
||||
this.syntax, this.destClass, this.expectedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class SquaredConverter implements Converter {
|
||||
|
||||
public <T> T convert(Object source, Class<T> toClass) throws Exception {
|
||||
@@ -184,49 +229,4 @@ public final class ConverterManagerTests {
|
||||
|
||||
}
|
||||
|
||||
// Tests using syntaxes for "finer grained" mapping
|
||||
@Test
|
||||
public void syntaxBasedConversion() throws Exception {
|
||||
Converter squaredConverter = new SquaredConverter();
|
||||
this.converterManager.addConverter(String.class, "1", Integer.class, squaredConverter);
|
||||
this.converterManager.addConverter(Integer.class, "1", Integer.class, squaredConverter);
|
||||
Converter cubedConverter = new CubedConverter();
|
||||
this.converterManager.addConverter(String.class, "2", Integer.class, cubedConverter);
|
||||
this.converterManager.addConverter(Integer.class, "3", Integer.class, cubedConverter);
|
||||
|
||||
final ConverterTestData<?>[] syntaxTests = new ConverterTestData<?>[] {
|
||||
new ConverterTestData<Integer>("3", "", Integer.class, Integer.valueOf(3)),
|
||||
new ConverterTestData<Integer>("4", "", Integer.class, Integer.valueOf(4)),
|
||||
new ConverterTestData<Integer>(5, "", Integer.class, Integer.valueOf(5)),
|
||||
new ConverterTestData<Integer>(6, "", Integer.class, Integer.valueOf(6)),
|
||||
new ConverterTestData<Integer>("3", "1", Integer.class, Integer.valueOf(9)),
|
||||
new ConverterTestData<Integer>("4", "1", Integer.class, Integer.valueOf(16)),
|
||||
new ConverterTestData<Integer>(5, "1", Integer.class, Integer.valueOf(25)),
|
||||
new ConverterTestData<Integer>(6, "1", Integer.class, Integer.valueOf(36)),
|
||||
new ConverterTestData<Integer>("3", "2", Integer.class, Integer.valueOf(27)),
|
||||
new ConverterTestData<Integer>("4", "2", Integer.class, Integer.valueOf(64)),
|
||||
new ConverterTestData<Integer>(5, "3", Integer.class, Integer.valueOf(125)),
|
||||
new ConverterTestData<Integer>(6, "3", Integer.class, Integer.valueOf(216)), };
|
||||
|
||||
new ExecuteRunnable<ConverterTestData<?>>().runTests(new RunnableTests<ConverterTestData<?>>() {
|
||||
public void runTest(ConverterTestData<?> testData) {
|
||||
assertEquals(testData.expectedValue, ConverterManagerTests.this.converterManager
|
||||
.convert(testData.sourceData, testData.syntax, testData.destClass));
|
||||
}
|
||||
}, syntaxTests);
|
||||
|
||||
}
|
||||
|
||||
// No converter for classes
|
||||
@Test(expected = ConverterException.class)
|
||||
public void noClassConverter() throws Exception {
|
||||
this.converterManager.convert(BitSet.class, "", Integer.class);
|
||||
}
|
||||
|
||||
// Invalid syntax so converter fails
|
||||
@Test(expected = ConverterException.class)
|
||||
public void invalidSyntax() throws Exception {
|
||||
this.converterManager.convert(String.class, "not a uri", URI.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import jdepend.framework.JDepend;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class JDependTests {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JDependTests {
|
||||
@Test
|
||||
public void testAllPackages() {
|
||||
this.jdepend.analyze();
|
||||
assertEquals(false, this.jdepend.containsCycles());
|
||||
assertThat(this.jdepend.containsCycles()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,13 +62,12 @@ import org.springframework.ldap.odm.typeconversion.impl.Converter;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.ConverterManagerImpl;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.converters.FromStringConverter;
|
||||
import org.springframework.ldap.odm.typeconversion.impl.converters.ToStringConverter;
|
||||
import org.springframework.ldap.query.LdapQueryBuilder;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
// Tests all OdmManager functions
|
||||
public final class LdapTests {
|
||||
@@ -124,8 +123,8 @@ public final class LdapTests {
|
||||
byte[] photoBytes = photoString.getBytes("US-ASCII");
|
||||
photo = Base64.getDecoder().decode(photoBytes);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException("Problem decoding photo", e);
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException("Problem decoding photo", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,27 +249,11 @@ public final class LdapTests {
|
||||
LOG.debug(String.format("reading - %1$s", dn));
|
||||
Person personEntry = LdapTests.this.odmManager.read(Person.class, dn);
|
||||
LOG.debug(String.format("read - %1$s", personEntry));
|
||||
assertEquals(testData, personEntry);
|
||||
assertThat(testData).isEqualTo(personEntry);
|
||||
}
|
||||
}, this.personTestData);
|
||||
}
|
||||
|
||||
private static class SearchTestData {
|
||||
|
||||
private String search;
|
||||
|
||||
private SearchControls searchScope;
|
||||
|
||||
private Person[] people;
|
||||
|
||||
public SearchTestData(String search, SearchControls searchScope, Person[] people) {
|
||||
this.search = search;
|
||||
this.searchScope = searchScope;
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SearchTestData[] searchTestData = {
|
||||
new SearchTestData("(sn=Unknown)", this.searchControls,
|
||||
new Person[] { this.personTestData[PersonName.DAVROS.getIndex()],
|
||||
@@ -293,7 +276,7 @@ public final class LdapTests {
|
||||
List<Person> results = LdapTests.this.odmManager.search(Person.class, baseName, testData.search,
|
||||
testData.searchScope);
|
||||
LOG.debug(String.format("found - %1$s", results));
|
||||
assertEquals(new HashSet<Person>(Arrays.asList(testData.people)), new HashSet<Person>(results));
|
||||
assertThat(new HashSet<Person>(Arrays.asList(testData.people))).isEqualTo(new HashSet<Person>(results));
|
||||
}
|
||||
}, this.searchTestData);
|
||||
}
|
||||
@@ -314,7 +297,7 @@ public final class LdapTests {
|
||||
|
||||
}
|
||||
|
||||
private static OrganizationalUnit ouTestData[] = new OrganizationalUnit[] {
|
||||
private static OrganizationalUnit[] ouTestData = new OrganizationalUnit[] {
|
||||
new OrganizationalUnit(LdapUtils.newLdapName("ou=Enemies,o=Whoniverse"), "Acacia Avenue", "The bad guys"),
|
||||
new OrganizationalUnit(LdapUtils.newLdapName("ou=Assistants,o=Whoniverse"), "Somewhere in space",
|
||||
"The plucky helpers"),
|
||||
@@ -328,14 +311,14 @@ public final class LdapTests {
|
||||
List<OrganizationalUnit> allOus = this.odmManager.findAll(OrganizationalUnit.class, baseName,
|
||||
this.searchControls);
|
||||
LOG.debug(String.format("Found - %1$s", allOus));
|
||||
assertEquals(new HashSet<OrganizationalUnit>(Arrays.asList(ouTestData)),
|
||||
new HashSet<OrganizationalUnit>(allOus));
|
||||
assertThat(new HashSet<OrganizationalUnit>(Arrays.asList(ouTestData)))
|
||||
.isEqualTo(new HashSet<OrganizationalUnit>(allOus));
|
||||
|
||||
OrganizationalUnit testOu = ouTestData[OrganizationalName.ASSISTANTS.getIndex()];
|
||||
LOG.debug(String.format("Reading - %1$s", testOu.getDn()));
|
||||
OrganizationalUnit ou = this.odmManager.read(OrganizationalUnit.class, testOu.getDn());
|
||||
LOG.debug(String.format("Found - %1$s", ou));
|
||||
assertEquals(testOu, ou);
|
||||
assertThat(testOu).isEqualTo(ou);
|
||||
}
|
||||
|
||||
// Find all entries managed by the OdmManager in the test data set and check they are
|
||||
@@ -345,44 +328,45 @@ public final class LdapTests {
|
||||
LOG.debug("finding all people");
|
||||
List<Person> allPeople = this.odmManager.findAll(Person.class, baseName, this.searchControls);
|
||||
LOG.debug(String.format("found %1$s", allPeople));
|
||||
assertEquals(new HashSet<Person>(Arrays.asList(this.personTestData)), new HashSet<Person>(allPeople));
|
||||
assertThat(new HashSet<Person>(Arrays.asList(this.personTestData))).isEqualTo(new HashSet<Person>(allPeople));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllAsPlainPersons() {
|
||||
List<PlainPerson> allPeople = this.odmManager.findAll(PlainPerson.class, baseName, this.searchControls);
|
||||
|
||||
assertEquals(9, allPeople.size());
|
||||
assertFalse("No nulls should have been returned", CollectionUtils.containsInstance(allPeople, null));
|
||||
assertThat(9).isEqualTo(allPeople.size());
|
||||
assertThat(CollectionUtils.containsInstance(allPeople, null)).isFalse()
|
||||
.withFailMessage("No nulls should have been returned");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifySearchOnPlainPerson() {
|
||||
List<PlainPerson> result = this.odmManager.search(PlainPerson.class, baseName, "(cn=William Hartnell)",
|
||||
this.searchControls);
|
||||
assertEquals(1, result.size());
|
||||
assertThat(1).isEqualTo(result.size());
|
||||
|
||||
PlainPerson foundPerson = result.get(0);
|
||||
assertEquals("William Hartnell", foundPerson.getCn());
|
||||
assertEquals("Hartnell", foundPerson.getSurname());
|
||||
assertThat("William Hartnell").isEqualTo(foundPerson.getCn());
|
||||
assertThat("Hartnell").isEqualTo(foundPerson.getSurname());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifySearchWithLdapQuery() {
|
||||
List<Person> result = this.odmManager.search(Person.class,
|
||||
query().base(baseName).where("cn").is("William Hartnell"));
|
||||
assertEquals(1, result.size());
|
||||
LdapQueryBuilder.query().base(baseName).where("cn").is("William Hartnell"));
|
||||
assertThat(1).isEqualTo(result.size());
|
||||
|
||||
Person foundPerson = result.get(0);
|
||||
assertEquals("William Hartnell", foundPerson.getCn());
|
||||
assertEquals("Hartnell", foundPerson.getSurname());
|
||||
assertThat("William Hartnell").isEqualTo(foundPerson.getCn());
|
||||
assertThat("Hartnell").isEqualTo(foundPerson.getSurname());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePlainPerson() {
|
||||
List<PlainPerson> result = this.odmManager.search(PlainPerson.class, baseName, "(cn=William Hartnell)",
|
||||
this.searchControls);
|
||||
assertEquals(1, result.size());
|
||||
assertThat(1).isEqualTo(result.size());
|
||||
|
||||
PlainPerson foundPerson = result.get(0);
|
||||
foundPerson.setSurname("Tjolahopp");
|
||||
@@ -391,7 +375,7 @@ public final class LdapTests {
|
||||
// Verify that the objectclass was not changed on the target object
|
||||
List<Person> updatedResult = this.odmManager.search(Person.class, baseName, "(cn=William Hartnell)",
|
||||
this.searchControls);
|
||||
assertEquals(1, updatedResult.size());
|
||||
assertThat(1).isEqualTo(updatedResult.size());
|
||||
}
|
||||
|
||||
private Person[] createTestData = {
|
||||
@@ -416,7 +400,7 @@ public final class LdapTests {
|
||||
LOG.debug(String.format("reading - %1$s", dn));
|
||||
Person personEntry = LdapTests.this.odmManager.read(Person.class, dn);
|
||||
LOG.debug(String.format("read - %1$s", personEntry));
|
||||
assertEquals(testData, personEntry);
|
||||
assertThat(testData).isEqualTo(personEntry);
|
||||
}
|
||||
}, this.createTestData);
|
||||
}
|
||||
@@ -430,7 +414,7 @@ public final class LdapTests {
|
||||
william.setSurname("Harvey");
|
||||
this.odmManager.update(william);
|
||||
Person readWilliam = this.odmManager.read(Person.class, william.getDn());
|
||||
assertEquals(william, readWilliam);
|
||||
assertThat(william).isEqualTo(readWilliam);
|
||||
}
|
||||
|
||||
private Person[] deleteData = { this.personTestData[PersonName.JON.getIndex()],
|
||||
@@ -450,7 +434,7 @@ public final class LdapTests {
|
||||
}
|
||||
|
||||
List<Person> allPeople = this.odmManager.findAll(Person.class, baseName, this.searchControls);
|
||||
assertEquals(new HashSet<Person>(Arrays.asList(this.whatsLeft)), new HashSet<Person>(allPeople));
|
||||
assertThat(new HashSet<Person>(Arrays.asList(this.whatsLeft))).isEqualTo(new HashSet<Person>(allPeople));
|
||||
}
|
||||
|
||||
// Trying to read a non-existant entry should be flagged as an error
|
||||
@@ -465,134 +449,48 @@ public final class LdapTests {
|
||||
this.odmManager.read(Person.class, LdapUtils.newLdapName("ou=Doctors,o=Whoniverse"));
|
||||
}
|
||||
|
||||
private final static class NoEntry {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
Name id;
|
||||
|
||||
}
|
||||
|
||||
// Every class to be managed must be annotated @Entry
|
||||
@Test(expected = MetaDataException.class)
|
||||
public void noEntryAnnotation() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(NoEntry.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
private final static class NoId {
|
||||
|
||||
}
|
||||
|
||||
// There must be a field with the @Id annotation
|
||||
@Test(expected = MetaDataException.class)
|
||||
public void noId() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(NoId.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
private final static class TwoIds {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name firstId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name secondId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public TwoIds() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Only one field may be annotated @Id
|
||||
@Test(expected = MetaDataException.class)
|
||||
public void twoIds() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(TwoIds.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class NoConstructor {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
public NoConstructor(String aValue) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// All Entry annotated classes must have a zero argument public constructor
|
||||
@Test(expected = InvalidEntryException.class)
|
||||
public void noConstructor() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(NoConstructor.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class AttributeOnId {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
@Attribute
|
||||
private Name id;
|
||||
|
||||
}
|
||||
|
||||
// It is illegal put put both the Id and the Attribute annotation on the same field
|
||||
@Test(expected = MetaDataException.class)
|
||||
public void attributeOnId() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(AttributeOnId.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class IdIsNotAName {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
// The field annotation with @Id must be of type javax.naming.Name
|
||||
@Test(expected = MetaDataException.class)
|
||||
public void idIsNotAName() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(IdIsNotAName.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class MissingConverter {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private BufferedImage image;
|
||||
|
||||
}
|
||||
|
||||
// The OdmManager should flag any missing converters when it is instantiated
|
||||
@Test(expected = InvalidEntryException.class)
|
||||
public void missingConverter() {
|
||||
((OdmManagerImpl) this.odmManager).addManagedClass(MissingConverter.class);
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class WrongClassForOc {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Attribute(name = "objectClass")
|
||||
private int ocs;
|
||||
|
||||
}
|
||||
|
||||
// The OdmManager should flag if the objectClass attribute is not of the appropriate
|
||||
// type
|
||||
@Test(expected = MetaDataException.class)
|
||||
@@ -613,7 +511,7 @@ public final class LdapTests {
|
||||
this.odmManager.update(organizationalUnit);
|
||||
|
||||
OrganizationalUnit updated = this.odmManager.read(OrganizationalUnit.class, organizationalUnit.getDn());
|
||||
assertEquals(organizationalUnit, updated);
|
||||
assertThat(organizationalUnit).isEqualTo(updated);
|
||||
}
|
||||
|
||||
private enum Flag {
|
||||
@@ -700,8 +598,8 @@ public final class LdapTests {
|
||||
try {
|
||||
cmd = parser.parse(options, argv);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
System.out.println(e.getMessage());
|
||||
catch (ParseException ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -721,4 +619,106 @@ public final class LdapTests {
|
||||
new String[] { "create", "delete", "findAll", "read", "search", "update", "testSecondOc" });
|
||||
}
|
||||
|
||||
private static class SearchTestData {
|
||||
|
||||
private String search;
|
||||
|
||||
private SearchControls searchScope;
|
||||
|
||||
private Person[] people;
|
||||
|
||||
public SearchTestData(String search, SearchControls searchScope, Person[] people) {
|
||||
this.search = search;
|
||||
this.searchScope = searchScope;
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final static class NoEntry {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
Name id;
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
private final static class NoId {
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
private final static class TwoIds {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name firstId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name secondId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public TwoIds() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class NoConstructor {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
public NoConstructor(String aValue) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class AttributeOnId {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
@Attribute
|
||||
private Name id;
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class IdIsNotAName {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class MissingConverter {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private BufferedImage image;
|
||||
|
||||
}
|
||||
|
||||
@Entry(objectClasses = "test")
|
||||
public final static class WrongClassForOc {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Id
|
||||
private Name id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Attribute(name = "objectClass")
|
||||
private int ocs;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,9 +99,59 @@ public final class OrganizationalUnit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("objectClasses=%1$s | dn=%2$s | ou=%3$s | street=%4$s | description=%5$s",
|
||||
this.objectClass, this.dn, this.ou, this.street, this.description);
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
OrganizationalUnit other = (OrganizationalUnit) obj;
|
||||
if (this.description == null) {
|
||||
if (other.description != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.description.equals(other.description)) {
|
||||
return false;
|
||||
}
|
||||
if (this.dn == null) {
|
||||
if (other.dn != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.dn.equals(other.dn)) {
|
||||
return false;
|
||||
}
|
||||
if (this.objectClass == null) {
|
||||
if (other.objectClass != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (this.objectClass.size() != other.objectClass.size()
|
||||
|| !(new HashSet<String>(this.objectClass)).equals(new HashSet<String>(other.objectClass))) {
|
||||
return false;
|
||||
}
|
||||
if (this.ou == null) {
|
||||
if (other.ou != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.ou.equals(other.ou)) {
|
||||
return false;
|
||||
}
|
||||
if (this.street == null) {
|
||||
if (other.street != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.street.equals(other.street)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,46 +167,9 @@ public final class OrganizationalUnit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OrganizationalUnit other = (OrganizationalUnit) obj;
|
||||
if (this.description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.description.equals(other.description))
|
||||
return false;
|
||||
if (this.dn == null) {
|
||||
if (other.dn != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.dn.equals(other.dn))
|
||||
return false;
|
||||
if (this.objectClass == null) {
|
||||
if (other.objectClass != null)
|
||||
return false;
|
||||
}
|
||||
else if (this.objectClass.size() != other.objectClass.size()
|
||||
|| !(new HashSet<String>(this.objectClass)).equals(new HashSet<String>(other.objectClass)))
|
||||
return false;
|
||||
if (this.ou == null) {
|
||||
if (other.ou != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.ou.equals(other.ou))
|
||||
return false;
|
||||
if (this.street == null) {
|
||||
if (other.street != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.street.equals(other.street))
|
||||
return false;
|
||||
return true;
|
||||
public String toString() {
|
||||
return String.format("objectClasses=%1$s | dn=%2$s | ou=%3$s | street=%4$s | description=%5$s",
|
||||
this.objectClass, this.dn, this.ou, this.street, this.description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,17 +138,82 @@ public final class Person {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder jpegString = new StringBuilder();
|
||||
if (this.jpegPhoto != null) {
|
||||
for (byte b : this.jpegPhoto) {
|
||||
jpegString.append(Byte.toString(b));
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Person other = (Person) obj;
|
||||
if (this.cn == null) {
|
||||
if (other.cn != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(
|
||||
"objectClasses=%1$s | dn=%2$s | cn=%3$s | sn=%4$s | desc=%5$s | telephoneNumber=%6$s | jpegPhoto=%7$s",
|
||||
this.objectClasses, this.dn, this.cn, this.surname, this.desc, this.telephoneNumber, jpegString);
|
||||
else if (!this.cn.equals(other.cn)) {
|
||||
return false;
|
||||
}
|
||||
if (this.desc == null) {
|
||||
if (other.desc != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (this.desc.size() != other.desc.size()
|
||||
|| !(new HashSet<String>(this.desc)).equals(new HashSet<String>(other.desc))) {
|
||||
return false;
|
||||
}
|
||||
if (this.dn == null) {
|
||||
if (other.dn != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.dn.equals(other.dn)) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.equals(this.jpegPhoto, other.jpegPhoto)) {
|
||||
return false;
|
||||
}
|
||||
if (this.objectClasses == null) {
|
||||
if (other.objectClasses != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (this.objectClasses.size() != other.objectClasses.size()
|
||||
|| !(new HashSet<String>(this.objectClasses)).equals(new HashSet<String>(other.objectClasses))) {
|
||||
return false;
|
||||
}
|
||||
if (this.someRandomField == null) {
|
||||
if (other.someRandomField != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.someRandomField.equals(other.someRandomField)) {
|
||||
return false;
|
||||
}
|
||||
if (this.someRandomList == null) {
|
||||
if (other.someRandomList != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.someRandomList.equals(other.someRandomList)) {
|
||||
return false;
|
||||
}
|
||||
if (this.surname == null) {
|
||||
if (other.surname != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.surname.equals(other.surname)) {
|
||||
return false;
|
||||
}
|
||||
if (this.telephoneNumber != other.telephoneNumber) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,63 +234,17 @@ public final class Person {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Person other = (Person) obj;
|
||||
if (this.cn == null) {
|
||||
if (other.cn != null)
|
||||
return false;
|
||||
public String toString() {
|
||||
StringBuilder jpegString = new StringBuilder();
|
||||
if (this.jpegPhoto != null) {
|
||||
for (byte b : this.jpegPhoto) {
|
||||
jpegString.append(Byte.toString(b));
|
||||
}
|
||||
}
|
||||
else if (!this.cn.equals(other.cn))
|
||||
return false;
|
||||
if (this.desc == null) {
|
||||
if (other.desc != null)
|
||||
return false;
|
||||
}
|
||||
else if (this.desc.size() != other.desc.size()
|
||||
|| !(new HashSet<String>(this.desc)).equals(new HashSet<String>(other.desc)))
|
||||
return false;
|
||||
if (this.dn == null) {
|
||||
if (other.dn != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.dn.equals(other.dn))
|
||||
return false;
|
||||
if (!Arrays.equals(this.jpegPhoto, other.jpegPhoto))
|
||||
return false;
|
||||
if (this.objectClasses == null) {
|
||||
if (other.objectClasses != null)
|
||||
return false;
|
||||
}
|
||||
else if (this.objectClasses.size() != other.objectClasses.size()
|
||||
|| !(new HashSet<String>(this.objectClasses)).equals(new HashSet<String>(other.objectClasses)))
|
||||
return false;
|
||||
if (this.someRandomField == null) {
|
||||
if (other.someRandomField != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.someRandomField.equals(other.someRandomField))
|
||||
return false;
|
||||
if (this.someRandomList == null) {
|
||||
if (other.someRandomList != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.someRandomList.equals(other.someRandomList))
|
||||
return false;
|
||||
if (this.surname == null) {
|
||||
if (other.surname != null)
|
||||
return false;
|
||||
}
|
||||
else if (!this.surname.equals(other.surname))
|
||||
return false;
|
||||
if (this.telephoneNumber != other.telephoneNumber)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
return String.format(
|
||||
"objectClasses=%1$s | dn=%2$s | cn=%3$s | sn=%4$s | desc=%5$s | telephoneNumber=%6$s | jpegPhoto=%7$s",
|
||||
this.objectClasses, this.dn, this.cn, this.surname, this.desc, this.telephoneNumber, jpegString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,31 +79,38 @@ public final class PlainPerson {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
if (this == o) {
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlainPerson that = (PlainPerson) o;
|
||||
|
||||
if (this.cn != null ? !this.cn.equals(that.cn) : that.cn != null)
|
||||
if ((this.cn != null) ? !this.cn.equals(that.cn) : that.cn != null) {
|
||||
return false;
|
||||
if (this.dn != null ? !this.dn.equals(that.dn) : that.dn != null)
|
||||
}
|
||||
if ((this.dn != null) ? !this.dn.equals(that.dn) : that.dn != null) {
|
||||
return false;
|
||||
if (this.objectClasses != null ? !this.objectClasses.equals(that.objectClasses) : that.objectClasses != null)
|
||||
}
|
||||
if ((this.objectClasses != null) ? !this.objectClasses.equals(that.objectClasses)
|
||||
: that.objectClasses != null) {
|
||||
return false;
|
||||
if (this.surname != null ? !this.surname.equals(that.surname) : that.surname != null)
|
||||
}
|
||||
if ((this.surname != null) ? !this.surname.equals(that.surname) : that.surname != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.objectClasses != null ? this.objectClasses.hashCode() : 0;
|
||||
result = 31 * result + (this.dn != null ? this.dn.hashCode() : 0);
|
||||
result = 31 * result + (this.cn != null ? this.cn.hashCode() : 0);
|
||||
result = 31 * result + (this.surname != null ? this.surname.hashCode() : 0);
|
||||
int result = (this.objectClasses != null) ? this.objectClasses.hashCode() : 0;
|
||||
result = 31 * result + ((this.dn != null) ? this.dn.hashCode() : 0);
|
||||
result = 31 * result + ((this.cn != null) ? this.cn.hashCode() : 0);
|
||||
result = 31 * result + ((this.surname != null) ? this.surname.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.ldap.odm.typeconversion.impl.converters.ToStringConve
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
// Tests the generation of entry Java classes from LDAP schema
|
||||
public final class SchemaToJavaTests {
|
||||
@@ -194,7 +194,7 @@ public final class SchemaToJavaTests {
|
||||
// Check some returned values
|
||||
Method getDnMethod = clazz.getMethod("getDn");
|
||||
Object dn = getDnMethod.invoke(fromDirectory);
|
||||
assertEquals(testDn, dn);
|
||||
assertThat(testDn).isEqualTo(dn);
|
||||
|
||||
Method getCnIteratorMethod = clazz.getMethod("getCnIterator");
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -202,9 +202,9 @@ public final class SchemaToJavaTests {
|
||||
int cnCount = 0;
|
||||
while (cnIterator.hasNext()) {
|
||||
cnCount++;
|
||||
assertEquals("William Hartnell", cnIterator.next());
|
||||
assertThat("William Hartnell").isEqualTo(cnIterator.next());
|
||||
}
|
||||
assertEquals(1, cnCount);
|
||||
assertThat(1).isEqualTo(cnCount);
|
||||
|
||||
Method telephoneNumberIteratorMethod = clazz.getMethod("getTelephoneNumberIterator");
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -213,14 +213,14 @@ public final class SchemaToJavaTests {
|
||||
int telephoneNumberCount = 0;
|
||||
while (telephoneNumberIterator.hasNext()) {
|
||||
telephoneNumberCount++;
|
||||
assertEquals(Integer.valueOf(1), telephoneNumberIterator.next());
|
||||
assertThat(Integer.valueOf(1)).isEqualTo(telephoneNumberIterator.next());
|
||||
}
|
||||
assertEquals(1, telephoneNumberCount);
|
||||
assertThat(1).isEqualTo(telephoneNumberCount);
|
||||
|
||||
// Reread and check whether equals and hashCode are at least sane
|
||||
Object fromDirectory2 = odmManager.read(clazz, testDn);
|
||||
assertEquals(fromDirectory, fromDirectory2);
|
||||
assertEquals(fromDirectory.hashCode(), fromDirectory2.hashCode());
|
||||
assertThat(fromDirectory).isEqualTo(fromDirectory2);
|
||||
assertThat(fromDirectory.hashCode()).isEqualTo(fromDirectory2.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.ldap.odm.tools.SchemaViewer;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.ldap.test.LdapTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public final class SchemaViewerTests {
|
||||
|
||||
@@ -99,22 +99,6 @@ public final class SchemaViewerTests {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class TestData {
|
||||
|
||||
private final String flag;
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String result;
|
||||
|
||||
public TestData(String flag, String value, String result) {
|
||||
this.flag = flag;
|
||||
this.value = value;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This makes the test dependent on the order in which the data is returned - it is
|
||||
// invalid to assume that this will not change
|
||||
private static TestData[] viewerTestData = new TestData[] { new TestData("-o", "top",
|
||||
@@ -133,9 +117,25 @@ public final class SchemaViewerTests {
|
||||
new ExecuteRunnable<TestData>().runTests(new RunnableTests<TestData>() {
|
||||
public void runTest(TestData testData) {
|
||||
String result = runSchemaViewer(testData.flag, testData.value);
|
||||
assertEquals(testData.result, result);
|
||||
assertThat(testData.result).isEqualTo(result);
|
||||
}
|
||||
}, viewerTestData);
|
||||
}
|
||||
|
||||
private static class TestData {
|
||||
|
||||
private final String flag;
|
||||
|
||||
private final String value;
|
||||
|
||||
private final String result;
|
||||
|
||||
public TestData(String flag, String value, String result) {
|
||||
this.flag = flag;
|
||||
this.value = value;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user