@Override public ENTProfil get(Name dn) { return template.findByDn(dn, ENTProfil.class); }
public <T> T read(Class<T> clazz, Name dn) { return ldapTemplate.findByDn(dn, clazz); }
public <T> T read(Class<T> clazz, Name dn) { return ldapTemplate.findByDn(dn, clazz); }
public <T> T read(Class<T> clazz, Name dn) { return ldapTemplate.findByDn(dn, clazz); }
public <T> T read(Class<T> clazz, Name dn) { return ldapTemplate.findByDn(dn, clazz); }
/** * {@inheritDoc} */ @Override public Person getPersonNoCache(Name dn) { return this.template.findByDn(dn, this.sample.getClass()); }
/** * {@inheritDoc} */ @Override public PortalGroup find(Name dn) throws NameNotFoundException { return this.template.findByDn(dn, this.sample.getClass()); }
/** * {@inheritDoc} */ @Override public Group get(Name dn) { return this.template.findByDn(dn, this.sample.getClass()); }
@Override public CollabProfile findByDn(Name dn) { return template.findByDn(dn, sample.getClass()); }
@Override public Role findByDn(Name dn) { return template.findByDn(dn, sample.getClass()); }
/** * {@inheritDoc} */ @Override @Cacheable(key = "#dn", value = {"personByDnCache"}) public Person getPerson(Name dn) throws NameNotFoundException { return this.template.findByDn(dn, this.sample.getClass()); }
@Cacheable(key = "#dn", value = { "structByDnCache" }) public ENTStructure getStructure(Name dn) throws NameNotFoundException { ENTStructure struct = template.findByDn(dn, sample.getClass()); return struct; }
@Test(expected = OdmException.class) public void testFindByDnThrowsExceptionOnInvalidEntry() { tested.findByDn(LdapUtils.newLdapName("ou=company1,ou=Sweden"), Person.class); }
@Test public void testFindByDn() { Person person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), Person.class); assertThat(person).isNotNull(); assertThat(person.getCommonName()).isEqualTo("Some Person3"); 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 public void testFindByDn() throws NamingException { expectGetReadOnlyContext(); Object transformed = new Object(); Class<Object> expectedClass = Object.class; DirContextAdapter expectedContext = new DirContextAdapter(); when(dirContextMock.lookup(nameMock)).thenReturn(expectedContext); when(odmMock.mapFromLdapDataEntry(expectedContext, expectedClass)).thenReturn(transformed); when(nameMock.getAll()).thenReturn(Collections.<String> enumeration(Collections.<String> emptyList())); // Perform test Object result = tested.findByDn(nameMock, expectedClass); assertThat(result).isSameAs(transformed); verify(odmMock).manageClass(expectedClass); }
@Test public void testFindByDn() { PersonWithDnAnnotations person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class); assertThat(person).isNotNull(); assertThat(person.getCommonName()).isEqualTo("Some Person3"); assertThat(person.getSurname()).isEqualTo("Person3"); assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3"); assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654"); // 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 public void testUpdate() { PersonWithDnAnnotations person = tested.findOne(query() .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( LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Sweden"), PersonWithDnAnnotations.class); assertThat(person.getCommonName()).isEqualTo("Some Person3"); 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 public void testCreateWithCalculatedDn() { PersonWithDnAnnotations person = new PersonWithDnAnnotations(); // Don't explicitly set DN. person.setCommonName("New Person"); person.setSurname("Person"); person.setDesc(Arrays.asList("This is the description")); person.setTelephoneNumber("0123456"); person.setCompany("company1"); person.setCountry("Sweden"); tested.create(person); assertThat(tested.findAll(PersonWithDnAnnotations.class)).hasSize(6); person = tested.findByDn(LdapUtils.newLdapName("cn=New Person,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class); assertThat(person.getCommonName()).isEqualTo("New Person"); assertThat(person.getSurname()).isEqualTo("Person"); assertThat(person.getDesc().get(0)).isEqualTo("This is the description"); assertThat(person.getTelephoneNumber()).isEqualTo("0123456"); // 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 public void testUpdateWithChangedDn() { PersonWithDnAnnotations person = tested.findOne(query() .where("cn").is("Some Person3"), PersonWithDnAnnotations.class); // 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( LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Norway"), PersonWithDnAnnotations.class); assertThat(person.getCommonName()).isEqualTo("Some Person3"); assertThat(person.getSurname()).isEqualTo("Person3"); 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()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty(); assertThat(person.getEntryUuid()).isNotEqualTo(entryUuid); } }