Skip to content

Commit

Permalink
[HQ-1665] Add ResourceEdge unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen committed May 26, 2009
1 parent 87a58c0 commit ea7a7af
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/org/hyperic/hq/hqapi1/test/ResourceEdgeDelete_test.java
@@ -0,0 +1,69 @@
/*
*
* NOTE: This copyright does *not* cover user programs that use HQ
* program services by normal system calls through the application
* program interfaces provided as part of the Hyperic Plug-in Development
* Kit or the Hyperic Client Development Kit - this is merely considered
* normal use of the program, and does *not* fall under the heading of
* "derived work".
*
* Copyright (C) [2008, 2009], Hyperic, Inc.
* This file is part of HQ.
*
* HQ is free software; you can redistribute it and/or modify
* it under the terms version 2 of the GNU General Public License as
* published by the Free Software Foundation. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
*/

package org.hyperic.hq.hqapi1.test;

import java.util.List;

import org.hyperic.hq.hqapi1.ResourceEdgeApi;
import org.hyperic.hq.hqapi1.types.Resource;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;
import org.hyperic.hq.hqapi1.types.StatusResponse;

public class ResourceEdgeDelete_test extends ResourceTestBase {

public ResourceEdgeDelete_test(String name) {
super(name);
}

public void testDeleteInvalidId() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
StatusResponse response = api.deleteResourceEdges("network", Integer.MAX_VALUE);
hqAssertFailureObjectNotFound(response);
}

public void testDeleteInvalidRelation() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
StatusResponse response = api.deleteResourceEdges("invalid", Integer.MAX_VALUE);
hqAssertFailureInvalidParameters(response);
}

public void testDelete() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();

// get top-level resources not associated with a network hierarchy
ResourcesResponse resourcesResponse = api.getParentResourcesByRelation("network", null, null, false);
List resources = resourcesResponse.getResource();

if (!resources.isEmpty()) {
// test delete using a top-level resource not associated with a network hierarchy
Resource r = (Resource) resources.get(0);
StatusResponse response = api.deleteResourceEdges("network", r.getId());
hqAssertSuccess(response);
}
}
}
98 changes: 98 additions & 0 deletions src/org/hyperic/hq/hqapi1/test/ResourceEdgeGet_test.java
@@ -0,0 +1,98 @@
/*
*
* NOTE: This copyright does *not* cover user programs that use HQ
* program services by normal system calls through the application
* program interfaces provided as part of the Hyperic Plug-in Development
* Kit or the Hyperic Client Development Kit - this is merely considered
* normal use of the program, and does *not* fall under the heading of
* "derived work".
*
* Copyright (C) [2008, 2009], Hyperic, Inc.
* This file is part of HQ.
*
* HQ is free software; you can redistribute it and/or modify
* it under the terms version 2 of the GNU General Public License as
* published by the Free Software Foundation. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
*/

package org.hyperic.hq.hqapi1.test;

import org.hyperic.hq.hqapi1.ResourceApi;
import org.hyperic.hq.hqapi1.ResourceEdgeApi;
import org.hyperic.hq.hqapi1.types.Agent;
import org.hyperic.hq.hqapi1.types.Resource;
import org.hyperic.hq.hqapi1.types.ResourceEdgesResponse;
import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;

public class ResourceEdgeGet_test extends ResourceTestBase {

public ResourceEdgeGet_test(String name) {
super(name);
}

public void testGetInvalidResourceEdgesById() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourceEdgesResponse response = api.getResourceEdges("network", Integer.MAX_VALUE, null, null);
hqAssertFailureObjectNotFound(response);
}

public void testGetResourceEdgesById() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
Resource r = getLocalPlatformResource(false, false);
ResourceEdgesResponse response = api.getResourceEdges("network", r.getId(), null, null);
hqAssertSuccess(response);
}

public void testGetResourceEdgesByName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourceEdgesResponse response = api.getResourceEdges("network", null, null, "local");
hqAssertSuccess(response);
}

public void testGetResourceEdgesByPrototype() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourceEdgesResponse response = api.getResourceEdges("network", null, "MacOSX", null);
hqAssertSuccess(response);
}

public void testGetInvalidParentResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("invalid", null, null, true);
hqAssertFailureInvalidParameters(response);
}

public void testGetParentResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", null, null, true);
hqAssertSuccess(response);
}

public void testGetParentResourcesByPrototype() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", "Cisco IOS", null, true);
hqAssertSuccess(response);
}

public void testGetParentResourcesByName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", null, "cisco", true);
hqAssertSuccess(response);
}

public void testGetParentResourcesByPrototypeAndName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", "Cisco IOS", "cisco", true);
hqAssertSuccess(response);
}
}
99 changes: 99 additions & 0 deletions src/org/hyperic/hq/hqapi1/test/ResourceEdgeSelect_test.java
@@ -0,0 +1,99 @@
/*
*
* NOTE: This copyright does *not* cover user programs that use HQ
* program services by normal system calls through the application
* program interfaces provided as part of the Hyperic Plug-in Development
* Kit or the Hyperic Client Development Kit - this is merely considered
* normal use of the program, and does *not* fall under the heading of
* "derived work".
*
* Copyright (C) [2008, 2009], Hyperic, Inc.
* This file is part of HQ.
*
* HQ is free software; you can redistribute it and/or modify
* it under the terms version 2 of the GNU General Public License as
* published by the Free Software Foundation. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
*/

package org.hyperic.hq.hqapi1.test;

import org.hyperic.hq.hqapi1.ResourceApi;
import org.hyperic.hq.hqapi1.ResourceEdgeApi;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;

public class ResourceEdgeSelect_test extends ResourceTestBase {

public ResourceEdgeSelect_test(String name) {
super(name);
}

public void testSelectResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getResourcesByNoRelation("network", null, null);
hqAssertSuccess(response);
}

public void testSelectInvalidResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getResourcesByNoRelation("invalid", null, null);
hqAssertFailureInvalidParameters(response);
}

public void testSelectParentResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", null, null, false);
hqAssertSuccess(response);
}

public void testSelectInvalidParentResources() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("invalid", null, null, false);
hqAssertFailureInvalidParameters(response);
}

public void testSelectResourcesByPrototype() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getResourcesByNoRelation("network", "MacOSX", null);
hqAssertSuccess(response);
}

public void testSelectParentResourcesByPrototype() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", "Xen Host", null, false);
hqAssertSuccess(response);
}

public void testSelectResourcesByName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getResourcesByNoRelation("network", null, "local");
hqAssertSuccess(response);
}

public void testSelectParentResourcesByName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", null, "xen", false);
hqAssertSuccess(response);
}

public void testSelectResourcesByPrototypeAndName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getResourcesByNoRelation("network", "Win32", "local");
hqAssertSuccess(response);
}

public void testSelectParentResourcesByPrototypeAndName() throws Exception {
ResourceEdgeApi api = getApi().getResourceEdgeApi();
ResourcesResponse response = api.getParentResourcesByRelation("network", "Xen Host", "xen", false);
hqAssertSuccess(response);
}
}

0 comments on commit ea7a7af

Please sign in to comment.