Search in sources :

Example 1 with CIMValue

use of org.sblim.wbem.cim.CIMValue in project opennms by OpenNMS.

the class VmwareViJavaAccessTest method testGetPropertyOfCimObject.

@Test
public void testGetPropertyOfCimObject() throws Exception {
    CIMObject obj1 = new CIMInstance();
    CIMProperty cimProperty1 = new CIMProperty();
    cimProperty1.setName("theKey");
    cimProperty1.setValue(new CIMValue("theValue", CIMDataType.getPredefinedType(CIMDataType.STRING)));
    obj1.addProperty(cimProperty1);
    CIMObject obj2 = new CIMInstance();
    CIMProperty cimProperty2 = new CIMProperty();
    cimProperty2.setName("theKey");
    cimProperty2.setValue(new CIMValue(null, CIMDataType.getPredefinedType(CIMDataType.STRING)));
    obj2.addProperty(cimProperty2);
    CIMObject obj3 = new CIMInstance();
    CIMProperty cimProperty3 = new CIMProperty();
    obj3.addProperty(cimProperty3);
    Assert.assertEquals(vmwareViJavaAccess.getPropertyOfCimObject(obj1, "theKey"), "theValue");
    Assert.assertNull(vmwareViJavaAccess.getPropertyOfCimObject(obj2, "theKey"));
    Assert.assertNull(vmwareViJavaAccess.getPropertyOfCimObject(obj3, "theKey"));
}
Also used : CIMObject(org.sblim.wbem.cim.CIMObject) CIMProperty(org.sblim.wbem.cim.CIMProperty) CIMInstance(org.sblim.wbem.cim.CIMInstance) CIMValue(org.sblim.wbem.cim.CIMValue) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 CIMInstance (org.sblim.wbem.cim.CIMInstance)1 CIMObject (org.sblim.wbem.cim.CIMObject)1 CIMProperty (org.sblim.wbem.cim.CIMProperty)1 CIMValue (org.sblim.wbem.cim.CIMValue)1