@Test public void testUpdate() { String username = getTestRequiredProperty("testUser"); final Uid uid = new Uid(username); createTestUser(); FindUidObjectHandler handler = new FindUidObjectHandler(new Uid(username)); OperationOptionsBuilder builder = new OperationOptionsBuilder(); builder.setAttributesToGet(Arrays.asList(Name.NAME, DB2Connector.USER_AUTH_GRANTS)); OperationOptions options = builder.build(); facade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); ConnectorObject actual = handler.getFoundObject(); assertNotNull(actual); Attribute grants1 = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS); Attribute oldGrants = grants1; grants1 = AttributeBuilder.build(DB2Connector.USER_AUTH_GRANTS, "LOAD ON DATABASE", "SELECT ON SYSCAT.TABLES"); Set<Attribute> attributes = new HashSet<Attribute>(); attributes.add(grants1); Map<String, Object> emptyMap = Collections.emptyMap(); facade.addAttributeValues(ObjectClass.ACCOUNT, uid, attributes, new OperationOptions( emptyMap)); facade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); actual = handler.getFoundObject(); List<Object> newGrantsValue = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS).getValue(); assertTrue(newGrantsValue.contains("LOAD ON DATABASE")); assertTrue(newGrantsValue.contains("CONNECT ON DATABASE")); assertTrue(newGrantsValue.contains("SELECT ON SYSCAT.TABLES")); handler.clear(); attributes.clear(); attributes.add(AttributeBuilder.build(DB2Connector.USER_AUTH_GRANTS, "SELECT ON SYSCAT.TABLES")); facade.update(ObjectClass.ACCOUNT, uid, attributes, new OperationOptions(emptyMap)); facade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); actual = handler.getFoundObject(); newGrantsValue = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS).getValue(); assertFalse(newGrantsValue.contains("LOAD ON DATABASE")); assertTrue(newGrantsValue.contains("CONNECT ON DATABASE")); assertTrue(newGrantsValue.contains("SELECT ON SYSCAT.TABLES")); handler.clear(); facade.removeAttributeValues(ObjectClass.ACCOUNT, uid, AttributeUtil.filterUid(attributes), new OperationOptions(emptyMap)); facade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); actual = handler.getFoundObject(); newGrantsValue = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS).getValue(); assertFalse(newGrantsValue.contains("LOAD ON DATABASE")); assertTrue(newGrantsValue.contains("CONNECT ON DATABASE")); assertFalse(newGrantsValue.contains("SELECT ON SYSCAT.TABLES")); final DB2Configuration testConfiguration = DB2ConfigurationTest.createTestConfiguration(); testConfiguration.setReplaceAllGrantsOnUpdate(true); ConnectorFacade testFacade = createFacade(testConfiguration); attributes.clear(); attributes.add(AttributeBuilder.build(DB2Connector.USER_AUTH_GRANTS, "SELECT ON SYSCAT.TABLES")); testFacade.update(ObjectClass.ACCOUNT, uid, attributes, new OperationOptions(emptyMap)); testFacade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); actual = handler.getFoundObject(); newGrantsValue = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS).getValue(); assertFalse(newGrantsValue.contains("LOAD ON DATABASE")); assertTrue(newGrantsValue.contains("CONNECT ON DATABASE")); assertTrue(newGrantsValue.contains("SELECT ON SYSCAT.TABLES")); testConfiguration.setReplaceAllGrantsOnUpdate(false); testFacade = createFacade(testConfiguration); attributes.clear(); attributes.add(AttributeBuilder.build(DB2Connector.USER_AUTH_GRANTS, "LOAD ON DATABASE")); testFacade.update(ObjectClass.ACCOUNT, uid, attributes, new OperationOptions(emptyMap)); testFacade.search(ObjectClass.ACCOUNT, new EqualsFilter(uid), handler, options); actual = handler.getFoundObject(); newGrantsValue = actual.getAttributeByName(DB2Connector.USER_AUTH_GRANTS).getValue(); assertTrue(newGrantsValue.contains("LOAD ON DATABASE")); assertTrue(newGrantsValue.contains("CONNECT ON DATABASE")); assertTrue(newGrantsValue.contains("SELECT ON SYSCAT.TABLES")); attributes.clear(); attributes.add(oldGrants); facade.update(ObjectClass.ACCOUNT, uid, attributes, new OperationOptions(emptyMap)); }
public Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options) { if (cfg.isReplaceAllGrantsOnUpdate()) { return update(UpdateType.REPLACE, objclass, AttributeUtil.addUid(attrs, uid), options); } else { return update(UpdateType.ADD, objclass, AttributeUtil.addUid(attrs, uid), options); } }
DB2Connector implements AuthenticateOp, SchemaOp, CreateOp,
        SearchOp<FilterWhereBuilder>, DeleteOp, UpdateAttributeValuesOp, TestOp, PoolableConnector,
        AttributeNormalizer { public Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options) { if (cfg.isReplaceAllGrantsOnUpdate()) { return update(UpdateType.REPLACE, objclass, AttributeUtil.addUid(attrs, uid), options); } else { return update(UpdateType.ADD, objclass, AttributeUtil.addUid(attrs, uid), options); } } }
DB2Connector implements AuthenticateOp, SchemaOp, CreateOp,
        SearchOp<FilterWhereBuilder>, DeleteOp, UpdateAttributeValuesOp, TestOp, PoolableConnector,
        AttributeNormalizer { public Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options) { if (cfg.isReplaceAllGrantsOnUpdate()) { return update(UpdateType.REPLACE, objclass, AttributeUtil.addUid(attrs, uid), options); } else { return update(UpdateType.ADD, objclass, AttributeUtil.addUid(attrs, uid), options); } } DB2Connector(); }
DB2Connector implements AuthenticateOp, SchemaOp, CreateOp,
        SearchOp<FilterWhereBuilder>, DeleteOp, UpdateAttributeValuesOp, TestOp, PoolableConnector,
        AttributeNormalizer { public Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options) { if (cfg.isReplaceAllGrantsOnUpdate()) { return update(UpdateType.REPLACE, objclass, AttributeUtil.addUid(attrs, uid), options); } else { return update(UpdateType.ADD, objclass, AttributeUtil.addUid(attrs, uid), options); } } DB2Connector(); Uid authenticate(ObjectClass objectClass, String username, GuardedString password,
            OperationOptions options); Schema schema(); void checkAlive(); void dispose(); DB2Configuration getConfiguration(); void init(Configuration cfg); FilterTranslator<FilterWhereBuilder> createFilterTranslator(ObjectClass oclass,
            OperationOptions options); void executeQuery(ObjectClass oclass, FilterWhereBuilder where, ResultsHandler handler,
            OperationOptions options); Uid create(ObjectClass oclass, Set<Attribute> attrs, OperationOptions options); void delete(ObjectClass objClass, Uid uid, OperationOptions options); void test(); Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options); Uid addAttributeValues(ObjectClass objclass, Uid uid, Set<Attribute> valuesToAdd,
            OperationOptions options); Uid removeAttributeValues(ObjectClass objclass, Uid uid, Set<Attribute> valuesToRemove,
            OperationOptions options); Attribute normalizeAttribute(ObjectClass oclass, Attribute attribute); }
DB2Connector implements AuthenticateOp, SchemaOp, CreateOp,
        SearchOp<FilterWhereBuilder>, DeleteOp, UpdateAttributeValuesOp, TestOp, PoolableConnector,
        AttributeNormalizer { public Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options) { if (cfg.isReplaceAllGrantsOnUpdate()) { return update(UpdateType.REPLACE, objclass, AttributeUtil.addUid(attrs, uid), options); } else { return update(UpdateType.ADD, objclass, AttributeUtil.addUid(attrs, uid), options); } } DB2Connector(); Uid authenticate(ObjectClass objectClass, String username, GuardedString password,
            OperationOptions options); Schema schema(); void checkAlive(); void dispose(); DB2Configuration getConfiguration(); void init(Configuration cfg); FilterTranslator<FilterWhereBuilder> createFilterTranslator(ObjectClass oclass,
            OperationOptions options); void executeQuery(ObjectClass oclass, FilterWhereBuilder where, ResultsHandler handler,
            OperationOptions options); Uid create(ObjectClass oclass, Set<Attribute> attrs, OperationOptions options); void delete(ObjectClass objClass, Uid uid, OperationOptions options); void test(); Uid update(ObjectClass objclass, Uid uid, Set<Attribute> attrs, OperationOptions options); Uid addAttributeValues(ObjectClass objclass, Uid uid, Set<Attribute> valuesToAdd,
            OperationOptions options); Uid removeAttributeValues(ObjectClass objclass, Uid uid, Set<Attribute> valuesToRemove,
            OperationOptions options); Attribute normalizeAttribute(ObjectClass oclass, Attribute attribute);  }