Permalink
Browse files

Add Application WADL bindings, tests.

  • Loading branch information...
1 parent 120fb8c commit 5fe44ec632cad867e1e98f114e8fc58865e74aab Ryan Morgan committed Sep 28, 2009
@@ -0,0 +1,99 @@
+package org.hyperic.hq.hqapi1.test;
+
+import org.hyperic.hq.hqapi1.wadl.Endpoint;
+import org.hyperic.hq.hqapi1.wadl.*;
+
+import java.util.Random;
+
+public class WADLApplication_test extends WADLTestBase {
+
+ protected static final String APP_NAME = "Test Application";
+ protected static final String APP_LOCATION = "SFO";
+ protected static final String APP_DESC = "Test Application Description";
+ protected static final String APP_ENG_CONTACT = "415-555-5555";
+ protected static final String APP_BIZ_CONTACT = "212-555-5555";
+ protected static final String APP_OPS_CONTACT = "510-555-5555";
+
+ protected Application generateTestApplication()
+ throws Exception {
+
+ Random r = new Random();
+ Application a = new Application();
+
+ String name = APP_NAME + r.nextInt();
+ a.setName(name);
+ a.setLocation(APP_LOCATION);
+ a.setDescription(APP_DESC);
+ a.setEngContact(APP_ENG_CONTACT);
+ a.setBizContact(APP_BIZ_CONTACT);
+ a.setOpsContact(APP_OPS_CONTACT);
+
+ return a;
+ }
+
+ public void testList() throws Exception {
+ Endpoint.ApplicationListHqu list =
+ new Endpoint.ApplicationListHqu();
+
+ ApplicationsResponse response = list.getAsApplicationsResponse();
+ hqAssertSuccess(response);
+ }
+
+ public void testCreate() throws Exception {
+ Endpoint.ApplicationCreateHqu create =
+ new Endpoint.ApplicationCreateHqu();
+
+ Application a = generateTestApplication();
+ ApplicationRequest req = new ApplicationRequest();
+ req.setApplication(a);
+
+ ApplicationResponse response =
+ create.postAsApplicationResponse(req);
+ hqAssertSuccess(response);
+
+ Endpoint.ApplicationDeleteHqu delete =
+ new Endpoint.ApplicationDeleteHqu();
+ StatusResponse deleteResponse =
+ delete.getAsStatusResponse(response.getApplication().getId());
+ hqAssertSuccess(deleteResponse);
+ }
+
+ public void testUpdate() throws Exception {
+ Endpoint.ApplicationUpdateHqu update =
+ new Endpoint.ApplicationUpdateHqu();
+
+ Application a = generateTestApplication();
+ ApplicationRequest req = new ApplicationRequest();
+ req.setApplication(a);
+
+ ApplicationResponse resp = update.postAsApplicationResponse(req);
+ hqAssertFailure(resp);
+ }
+
+ public void testSync() throws Exception {
+ Endpoint.ApplicationSyncHqu sync =
+ new Endpoint.ApplicationSyncHqu();
+
+ Application a = generateTestApplication();
+ ApplicationsRequest req = new ApplicationsRequest();
+ req.getApplication().add(a);
+
+ ApplicationsResponse response = sync.postAsApplicationsResponse(req);
+ hqAssertSuccess(response);
+
+ Endpoint.ApplicationDeleteHqu delete =
+ new Endpoint.ApplicationDeleteHqu();
+ for (Application app : response.getApplication()) {
+ StatusResponse deleteResponse = delete.getAsStatusResponse(app.getId());
+ hqAssertSuccess(deleteResponse);
+ }
+ }
+
+ public void testDelete() throws Exception {
+ Endpoint.ApplicationDeleteHqu delete =
+ new Endpoint.ApplicationDeleteHqu();
+
+ StatusResponse deleteResponse = delete.getAsStatusResponse(Integer.MAX_VALUE);
+ hqAssertFailure(deleteResponse);
+ }
+}
@@ -7,7 +7,7 @@
import java.net.Authenticator;
import java.net.PasswordAuthentication;
-public class WADLTestBase extends TestCase {
+public abstract class WADLTestBase extends TestCase {
public void setUp() throws Exception {
final String username ="hqadmin";
View
@@ -1116,6 +1116,87 @@
</wadl:method>
</wadl:resource>
+ <wadl:resource path="application/list.hqu">
+ <wadl:doc title="HQApi Application list command">
+ List Applications
+ </wadl:doc>
+ <wadl:method name="GET" id="ApplicationList">
+ <wadl:request/>
+ <wadl:response>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationsResponse"/>
+ </wadl:response>
+ </wadl:method>
+ </wadl:resource>
+
+ <wadl:resource path="application/sync.hqu">
+ <wadl:doc title="HQApi Role sync command">
+ Sync Applications
+ </wadl:doc>
+ <wadl:method name="POST" id="ApplicationSync">
+ <wadl:request>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationsRequest"/>
+ </wadl:request>
+ <wadl:response>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationsResponse"/>
+ </wadl:response>
+ </wadl:method>
+ </wadl:resource>
+
+ <wadl:resource path="application/create.hqu">
+ <wadl:doc title="HQApi Application create command">
+ Create an Application
+ </wadl:doc>
+ <wadl:method name="POST" id="ApplicationCreate">
+ <wadl:request>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationRequest"/>
+ </wadl:request>
+ <wadl:response>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationResponse"/>
+ </wadl:response>
+ </wadl:method>
+ </wadl:resource>
+
+ <wadl:resource path="application/update.hqu">
+ <wadl:doc title="HQApi Application update command">
+ Sync Roles
+ </wadl:doc>
+ <wadl:method name="POST" id="ApplicationUpdate">
+ <wadl:request>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationRequest"/>
+ </wadl:request>
+ <wadl:response>
+ <wadl:representation mediaType="application/xml"
+ element="ApplicationResponse"/>
+ </wadl:response>
+ </wadl:method>
+ </wadl:resource>
+
+ <wadl:resource path="application/delete.hqu">
+ <wadl:doc title="HQApi Application delete command">
+ Delete an Application
+ </wadl:doc>
+ <wadl:method name="GET" id="ApplicationDelete">
+ <wadl:request>
+ <wadl:param name="id" style="query" required="true"
+ type="xs:int">
+ <wadl:doc>
+ The id of the Application to delete.
+ </wadl:doc>
+ </wadl:param>
+ </wadl:request>
+ <wadl:response>
+ <wadl:representation mediaType="application/xml"
+ element="StatusResponse"/>
+ </wadl:response>
+ </wadl:method>
+ </wadl:resource>
+
</wadl:resources>
</wadl:application>

0 comments on commit 5fe44ec

Please sign in to comment.