/** * Returns a attribute given it's id * * @param attributeId * The attribute Id * @return The attribute if it exists */ public Attribute get( String attributeId ) { if ( "dn".equalsIgnoreCase( attributeId ) ) { return new BasicAttribute( "dn", dn ); } return attributeList.get( attributeId ); }
/** * Add an attribute value to an existing attribute * * @param id * The attribute ID * * @param value * The attribute value * */ public void putAttribute( String id, Object value ) { Attribute attribute = attributeList.get( id ); if ( attribute != null ) { attribute.add( value ); } else { attributeList.put( id, value ); } }
@Test public void testResetAttributeValuesNotReportedAsModifications() { BasicAttributes attrs = new BasicAttributes("myattr", "a"); attrs.get("myattr").add("b"); attrs.get("myattr").add("c"); UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName()); ctx.setAttributeValues("myattr", new String[] { "a", "b" }); ctx.setAttributeValues("myattr", new String[] { "a", "b", "c" }); assertThat(ctx.getModificationItems().length).isEqualTo(0); }
@Test public void testResetAttributeValuesSameLengthNotReportedAsModifications() { BasicAttributes attrs = new BasicAttributes("myattr", "a"); attrs.get("myattr").add("b"); attrs.get("myattr").add("c"); UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName()); ctx.setAttributeValues("myattr", new String[] { "a", "b", "d" }); ctx.setAttributeValues("myattr", new String[] { "a", "b", "c" }); assertThat(ctx.getModificationItems().length).isEqualTo(0); }