/** * {@inheritDoc} */ @Override public void create(PortalGroup portalGroup) { this.template.create(portalGroup); }
@Override public void create(CollabProfile profile) { template.create(profile); }
@Override public void create(ENTCollabProfile profile) { template.create(profile); }
public void create(Object entry) { ldapTemplate.create(entry); }
@Override public void create(Role role) { template.create(role); }
public void create(Object entry) { ldapTemplate.create(entry); }
public void create(Object entry) { ldapTemplate.create(entry); }
public void create(Object entry) { ldapTemplate.create(entry); }
/** * {@inheritDoc} */ @Override public void create(Person person) { Name dn = this.sample.buildDn(person.getUid()); person.setDn(dn); this.template.create(person); }
@Test public void testCreateWithNoIdAvailableThrows() throws NamingException { Object expectedObject = new Object(); when(odmMock.getId(expectedObject)).thenReturn(null); when(odmMock.getCalculatedId(expectedObject)).thenReturn(null); try { tested.create(expectedObject); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } }
@Test public void testCreateWithIdSpecified() throws NamingException { expectGetReadWriteContext(); Object expectedObject = new Object(); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); when(odmMock.getId(expectedObject)).thenReturn(expectedName); ArgumentCaptor<DirContextAdapter> ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class); doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); tested.create(expectedObject); verify(odmMock, never()).setId(expectedObject, expectedName); verify(dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); verify(dirContextMock).close(); }
@Test public void testCreateWithCalculatedId() throws NamingException { expectGetReadWriteContext(); Object expectedObject = new Object(); LdapName expectedName = LdapUtils.newLdapName("ou=someOu"); when(odmMock.getId(expectedObject)).thenReturn(null); when(odmMock.getCalculatedId(expectedObject)).thenReturn(expectedName); ArgumentCaptor<DirContextAdapter> ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class); doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture()); tested.create(expectedObject); verify(odmMock).setId(expectedObject, expectedName); verify(dirContextMock).bind(expectedName, ctxCaptor.getValue(), null); verify(dirContextMock).close(); }
@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 testCreate() { Person person = new Person(); person.setDn(LdapNameBuilder.newInstance("ou=company1,ou=Sweden") .add("cn", "New Person").build()); person.setCommonName("New Person"); person.setSurname("Person"); person.setDesc(Arrays.asList("This is the description")); person.setTelephoneNumber("0123456"); tested.create(person); assertThat(tested.findAll(Person.class)).hasSize(6); person = tested.findOne(query() .where("cn").is("New Person"), Person.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"); assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty(); }