ConnectorObject obj = connectorFacade.getObject(objClass, uid, opOptions); Assert.assertNull("The deleted object was found. It should be no longer on the resource.", obj); deleted = true;
/** * Gets the ConnectorObject and check the value of attribute is as * expected * * @param uid Uid of object to get * @param expValue expected value of the attribute * @param type expected type of the attribute */ private void checkAttribute(ObjectClass objectClass, String attrName, Uid uid, Object expValue, Class<?> type) { //get the object ConnectorObject obj = getConnectorFacade().getObject(objectClass, uid, null); //check we have the correct value obj.getAttributes().stream(). filter(attribute -> attribute.is(attrName)). forEach(attribute -> { List<Object> vals = attribute.getValue(); assertTrue(vals.size() == 1, String.format( "Operational attribute %s must contain exactly one value.", attrName)); Object val = vals.get(0); assertEquals(type, val.getClass(), String.format( "Operational attribute %s value type must be %s, but is %s.", attrName, type.getSimpleName(), val.getClass().getSimpleName())); assertEquals(expValue, val, String.format( "Operational attribute %s value is different, expected: %s, returned: %s", attrName, expValue, val)); }); }
/** * Gets the ConnectorObject and check the value of attribute is as * expected * * @param uid Uid of object to get * @param expValue expected value of the attribute * @param type expected type of the attribute */ private void checkAttribute(String attrName, Uid uid, Object expValue, Class<?> type) { //get the object ConnectorObject obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, null); //check we have the correct value for (Attribute attribute : obj.getAttributes()) { if (attribute.is(attrName)) { List<Object> vals = attribute.getValue(); assertTrue(String.format("Operational attribute %s must contain exactly one value.", attrName), vals.size() == 1); Object val = vals.get(0); assertEquals(String.format( "Operational attribute %s value type must be %s, but is %s.", attrName, type.getSimpleName(), val.getClass().getSimpleName()), type, val.getClass()); assertEquals(String.format("Operational attribute %s value is different, expected: %s, returned: %s", attrName, expValue, val), expValue, val); } } }
/** * Gets the ConnectorObject and check the value of attribute is as * expected * * @param uid Uid of object to get * @param expValue expected value of the attribute * @param type expected type of the attribute */ private void checkAttribute(String attrName, Uid uid, Object expValue, Class<?> type) { //get the object ConnectorObject obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, null); //check we have the correct value for (Attribute attribute : obj.getAttributes()) { if (attribute.is(attrName)) { List<Object> vals = attribute.getValue(); assertTrue(String.format("Operational attribute %s must contain exactly one value.", attrName), vals.size() == 1); Object val = vals.get(0); assertEquals(String.format( "Operational attribute %s value type must be %s, but is %s.", attrName, type.getSimpleName(), val.getClass().getSimpleName()), type, val.getClass()); assertEquals(String.format("Operational attribute %s value is different, expected: %s, returned: %s", attrName, expValue, val), expValue, val); } } }
/** get the name for uid */ private String getName(ObjectClass objectClass, Uid uid) { OperationOptionsBuilder oob = new OperationOptionsBuilder(); oob.setAttributesToGet(Name.NAME); ConnectorObject o = getConnectorFacade().getObject(objectClass, uid, oob.build()); // get the name Attribute attrName = o.getAttributeByName(Name.NAME); return attrName.getValue().get(0).toString(); }
/** get the name for uid */ private String getName(Uid uid) { OperationOptionsBuilder oob = new OperationOptionsBuilder(); oob.setAttributesToGet(Name.NAME); ConnectorObject o = getConnectorFacade().getObject(getObjectClass(), uid, oob.build()); // get the name Attribute attrName = o.getAttributeByName(Name.NAME); return attrName.getValue().get(0).toString(); }
/** get the name for uid */ private String getName(Uid uid) { OperationOptionsBuilder oob = new OperationOptionsBuilder(); oob.setAttributesToGet(Name.NAME); ConnectorObject o = getConnectorFacade().getObject(getObjectClass(), uid, oob.build()); // get the name Attribute attrName = o.getAttributeByName(Name.NAME); return attrName.getValue().get(0).toString(); }
/** * Performs deletion of object specified by uid. Fails in case failOnError is true and object wasn't deleted during * delete call. */ public static boolean deleteObject(ConnectorFacade connectorFacade, ObjectClass objClass, Uid uid, boolean failOnError, OperationOptions opOptions) { boolean deleted = false; assertFalse( "Connector helper deleteObject method received a null Uid, when it was told it should not fail", (failOnError && (uid == null))); if (uid == null) { return deleted; } try { connectorFacade.delete(objClass, uid, opOptions); } catch (Throwable t) { if (failOnError) { fail( "Connector helper deleteObject method caught an exception, when it was told it should not fail"); } } if (failOnError) { // at present javadoc for delete is not clear about what // happens if delete fails, so I'll verify it's gone by searching ConnectorObject obj = connectorFacade.getObject(objClass, uid, opOptions); assertNull("The deleted object was found. It should be no longer on the resource.", obj); deleted = true; } return deleted; }
/** * Performs deletion of object specified by uid. * Fails in case failOnError is true and object wasn't deleted during delete call. */ public static boolean deleteObject(ConnectorFacade connectorFacade, ObjectClass objClass, Uid uid, boolean failOnError, OperationOptions opOptions) { boolean deleted = false; assertFalse((failOnError && (uid == null)), "Connector helper deleteObject method received a null Uid, when it was told it should not fail"); if (uid == null) { return deleted; } try { connectorFacade.delete(objClass, uid, opOptions); } catch (Throwable t) { if (failOnError) { fail("Connector helper deleteObject method caught an exception, when it was told it should not fail"); } } if (failOnError) { // at present javadoc for delete is not clear about what // happens if delete fails, so I'll verify it's gone by searching ConnectorObject obj = connectorFacade.getObject(objClass, uid, opOptions); assertNull(obj, "The deleted object was found. It should be no longer on the resource."); deleted = true; } return deleted; }
/** * {@inheritDoc} */ @Override protected void testRun(ObjectClass objectClass) { ConnectorObject obj = null; Uid uid = null; try { // create something to delete - object class is always supported uid = ConnectorHelper.createObject(getConnectorFacade(), getDataProvider(), getObjectClassInfo(objectClass), getTestName(), 0, getOperationOptionsByOp(objectClass, DeleteApiOp.class)); // The object should exist now obj = getConnectorFacade().getObject(objectClass, uid, getOperationOptionsByOp(objectClass, GetApiOp.class)); assertNotNull(obj, "Unable to perform delete test because object to be deleted cannot be created"); // try to delete object getConnectorFacade().delete(objectClass, uid, getOperationOptionsByOp(objectClass, DeleteApiOp.class)); // Try to find it now, it should be deleted obj = getConnectorFacade().getObject(objectClass, uid, getOperationOptionsByOp(objectClass, GetApiOp.class)); assertNull(obj, "Object wasn't deleted by delete."); } finally { // try to delete if previous deletes failed ConnectorHelper.deleteObject(getConnectorFacade(), objectClass, uid, false, getOperationOptionsByOp(objectClass, DeleteApiOp.class)); } }
/** * {@inheritDoc} */ @Override public void testRun() { ConnectorObject obj = null; Uid uid = null; try { // create something to delete - object class is always supported uid = ConnectorHelper.createObject(getConnectorFacade(), getDataProvider(), getObjectClassInfo(), getTestName(), 0, getOperationOptionsByOp(DeleteApiOp.class)); // The object should exist now obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to perform delete test because object to be deleted cannot be created", obj); // try to delete object getConnectorFacade().delete(getObjectClass(), uid, getOperationOptionsByOp(DeleteApiOp.class)); // Try to find it now, it should be deleted obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNull("Object wasn't deleted by delete.", obj); } finally { // try to delete if previous deletes failed ConnectorHelper.deleteObject(getConnectorFacade(), getSupportedObjectClass(), uid, false, getOperationOptionsByOp(DeleteApiOp.class)); } }
/** * {@inheritDoc} */ @Override public void testRun() { ConnectorObject obj = null; Uid uid = null; try { // create something to delete - object class is always supported uid = ConnectorHelper.createObject(getConnectorFacade(), getDataProvider(), getObjectClassInfo(), getTestName(), 0, getOperationOptionsByOp(DeleteApiOp.class)); // The object should exist now obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to perform delete test because object to be deleted cannot be created", obj); // try to delete object getConnectorFacade().delete(getObjectClass(), uid, getOperationOptionsByOp(DeleteApiOp.class)); // Try to find it now, it should be deleted obj = getConnectorFacade().getObject(getSupportedObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNull("Object wasn't deleted by delete.", obj); } finally { // try to delete if previous deletes failed ConnectorHelper.deleteObject(getConnectorFacade(), getSupportedObjectClass(), uid, false, getOperationOptionsByOp(DeleteApiOp.class)); } }
/** * {@inheritDoc} */ @Override protected void testRun(ObjectClass objectClass) { Uid uid = null; try { Set<Attribute> attrs = ConnectorHelper.getCreateableAttributes(getDataProvider(), getObjectClassInfo(objectClass), getTestName(), 0, true, false); // should throw UnsupportedObjectClass if not supported uid = getConnectorFacade().create(objectClass, attrs, getOperationOptionsByOp(objectClass, CreateApiOp.class)); // get the user to make sure it exists now ConnectorObject obj = getConnectorFacade().getObject(objectClass, uid, getOperationOptionsByOp(objectClass, GetApiOp.class)); assertNotNull(obj, "Unable to retrieve newly created object"); // compare requested attributes to retrieved attributes ConnectorHelper.checkObject(getObjectClassInfo(objectClass), obj, attrs); } finally { if (uid != null) { // delete the object getConnectorFacade().delete(objectClass, uid, getOperationOptionsByOp(objectClass, DeleteApiOp.class)); } } }
/** * {@inheritDoc} */ @Override public void testRun() { Uid uid = null; try { Set<Attribute> attrs = ConnectorHelper.getCreateableAttributes(getDataProvider(), getObjectClassInfo(), getTestName(), 0, true, false); // should throw UnsupportedObjectClass if not supported uid = getConnectorFacade().create(getObjectClass(), attrs, getOperationOptionsByOp(CreateApiOp.class)); // get the user to make sure it exists now ConnectorObject obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to retrieve newly created object", obj); // compare requested attributes to retrieved attributes ConnectorHelper.checkObject(getObjectClassInfo(), obj, attrs); } finally { if (uid != null) { // delete the object getConnectorFacade().delete(getSupportedObjectClass(), uid, getOperationOptionsByOp(DeleteApiOp.class)); } } }
/** * {@inheritDoc} */ @Override public void testRun() { Uid uid = null; try { Set<Attribute> attrs = ConnectorHelper.getCreateableAttributes(getDataProvider(), getObjectClassInfo(), getTestName(), 0, true, false); // should throw UnsupportedObjectClass if not supported uid = getConnectorFacade().create(getObjectClass(), attrs, getOperationOptionsByOp(CreateApiOp.class)); // get the user to make sure it exists now ConnectorObject obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to retrieve newly created object", obj); // compare requested attributes to retrieved attributes ConnectorHelper.checkObject(getObjectClassInfo(), obj, attrs); } finally { if (uid != null) { // delete the object getConnectorFacade().delete(getSupportedObjectClass(), uid, getOperationOptionsByOp(DeleteApiOp.class)); } } }
obj = getConnectorFacade().getObject(objectClass, uid, getOperationOptionsByOp(objectClass, GetApiOp.class)); assertNotNull(obj, "Unable to get object by uid");
obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to get object by uid", obj);
obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); assertNotNull("Unable to get object by uid", obj);
ConnectorObject obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); Assert.assertNotNull("Unable to retrieve newly created object", obj);
ConnectorObject obj = getConnectorFacade().getObject(getObjectClass(), uid, getOperationOptionsByOp(GetApiOp.class)); Assert.assertNotNull("Unable to retrieve newly created object", obj);