added ITs

This commit is contained in:
Konrad Windszus
2016-10-26 10:28:09 +02:00
committed by Rob Winch
parent 8dd61f9b6a
commit dd73c9c0a2
7 changed files with 77 additions and 44 deletions

View File

@@ -1,14 +1,15 @@
package org.springframework.ldap.itest.odm;
import java.util.List;
import javax.naming.Name;
import org.springframework.data.domain.Persistable;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import org.springframework.ldap.odm.annotations.Transient;
import javax.naming.Name;
import java.util.List;
/**
* @author Mattias Hellborg Arthursson
*/
@@ -35,6 +36,10 @@ public class Person implements Persistable<Name> {
@Transient
private boolean isNew = false;
// operational attribute according to https://tools.ietf.org/html/rfc4530
@Attribute(name = "entryUUID", readonly = true)
private String entryUuid;
@Override
public Name getId() {
return getDn();
@@ -96,4 +101,8 @@ public class Person implements Persistable<Name> {
public void setTelephoneNumber(String telephoneNumber) {
this.telephoneNumber = telephoneNumber;
}
public String getEntryUuid() {
return entryUuid;
}
}

View File

@@ -1,14 +1,15 @@
package org.springframework.ldap.itest.odm;
import java.util.List;
import javax.naming.Name;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.DnAttribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import org.springframework.ldap.odm.annotations.Transient;
import javax.naming.Name;
import java.util.List;
/**
* @author Mattias Hellborg Arthursson
*/
@@ -41,6 +42,10 @@ public class PersonWithDnAnnotations {
@Transient
private String country;
// operational attribute according to https://tools.ietf.org/html/rfc4530
@Attribute(name = "entryUUID", readonly = true)
private String entryUuid;
public Name getDn() {
return dn;
}
@@ -104,4 +109,8 @@ public class PersonWithDnAnnotations {
public void setCountry(String country) {
this.country = country;
}
public String getEntryUuid() {
return entryUuid;
}
}

View File

@@ -16,6 +16,13 @@
package org.springframework.ldap.itest.odm;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.LdapTemplate;
@@ -23,13 +30,6 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.test.context.ContextConfiguration;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
/**
* @author Mattias Hellborg Arthursson
*/
@@ -52,6 +52,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
// Automatically calculated
assertThat(person.getCompany()).isEqualTo("company1");
assertThat(person.getCountry()).isEqualTo("Sweden");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -68,6 +69,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
// Automatically calculated
assertThat(person.getCompany()).isEqualTo("company1");
assertThat(person.getCountry()).isEqualTo("Sweden");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -83,6 +85,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
// Automatically calculated
assertThat(person.getCompany()).isEqualTo("company1");
assertThat(person.getCountry()).isEqualTo("Sweden");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
private PersonWithDnAnnotations findPerson(List<PersonWithDnAnnotations> persons, String cn) {
@@ -124,6 +127,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
// Automatically calculated
assertThat(person.getCompany()).isEqualTo("company1");
assertThat(person.getCountry()).isEqualTo("Sweden");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -132,6 +136,8 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
.where("cn").is("Some Person3"), PersonWithDnAnnotations.class);
person.setDesc(Arrays.asList("New Description"));
String entryUuid = person.getEntryUuid();
assertThat(entryUuid).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
tested.update(person);
person = tested.findByDn(
@@ -142,6 +148,7 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("New Description");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).isEqualTo(entryUuid);
}
@Test
@@ -151,6 +158,8 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
// This should make the entry move
person.setCountry("Norway");
String entryUuid = person.getEntryUuid();
assertThat(entryUuid).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
tested.update(person);
person = tested.findByDn(
@@ -162,5 +171,6 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
assertThat(person.getCountry()).isEqualTo("Norway");
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).isEqualTo(entryUuid);
}
}

View File

@@ -16,6 +16,13 @@
package org.springframework.ldap.itest.odm;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
@@ -26,13 +33,6 @@ import org.springframework.ldap.support.LdapNameBuilder;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.test.context.ContextConfiguration;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
/**
* @author Mattias Hellborg Arthursson
*/
@@ -51,6 +51,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -62,6 +63,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test(expected = OdmException.class)
@@ -88,6 +90,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -129,6 +132,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertThat(person.getSurname()).isEqualTo("Person");
assertThat(person.getDesc().get(0)).isEqualTo("This is the description");
assertThat(person.getTelephoneNumber()).isEqualTo("0123456");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
@Test
@@ -137,6 +141,8 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
.where("cn").is("Some Person3"), Person.class);
person.setDesc(Arrays.asList("New Description"));
String entryUuid = person.getEntryUuid();
assertThat(entryUuid).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
tested.update(person);
person = tested.findOne(query()
@@ -146,6 +152,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("New Description");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).isEqualTo(entryUuid);
}
@Test