// Instance variables specific to this test.
private CollectionObjectClient client = new CollectionObjectClient();
final String SERVICE_PATH_COMPONENT = "collectionobjects";
- private String knownObjectId = null;
+ private String knownResourceId = null;
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// Submit the request to the service and store the response.
String identifier = createIdentifier();
- CollectionObject collectionObject = createCollectionObject(identifier);
+ CollectionObject collectionObject =
+ createCollectionObjectInstance(identifier);
ClientResponse<Response> res = client.create(collectionObject);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
//
+ // Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
verbose("create: status = " + statusCode);
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation for additional tests below.
- knownObjectId = extractId(res);
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ knownResourceId = extractId(res);
}
@Override
// Failure outcomes
@Override
- @Test(dependsOnMethods = {"create"}, expectedExceptions = IllegalArgumentException.class)
+ @Test(dependsOnMethods = {"create"},
+ expectedExceptions = IllegalArgumentException.class)
public void createNull() {
ClientResponse<Response> res = client.create(null);
}
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void createWithMalformedXml() {}
public void createWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
String url = getServiceRootURL();
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
final String entity = WRONG_XML_SCHEMA_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupRead();
// Submit the request to the service and store the response.
- ClientResponse<CollectionObject> res = client.read(knownObjectId);
+ ClientResponse<CollectionObject> res = client.read(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("read: status = " + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
ClientResponse<CollectionObject> res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
CollectionObjectList list = res.getEntity();
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readList: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
list.getCollectionObjectListItem();
int i = 0;
for(CollectionObjectList.CollectionObjectListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" + item.getCsid());
- verbose("readList: list-item[" + i + "] objectNumber=" + item.getObjectNumber());
- verbose("readList: list-item[" + i + "] URI=" + item.getUri());
+ verbose("readList: list-item[" + i + "] csid=" +
+ item.getCsid());
+ verbose("readList: list-item[" + i + "] objectNumber=" +
+ item.getObjectNumber());
+ verbose("readList: list-item[" + i + "] URI=" +
+ item.getUri());
i++;
}
}
setupUpdate();
// Retrieve an existing resource that we can update.
- ClientResponse<CollectionObject> res = client.read(knownObjectId);
+ ClientResponse<CollectionObject> res = client.read(knownResourceId);
verbose("read: status = " + res.getStatus());
Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
CollectionObject collectionObject = res.getEntity();
- verbose("Got object to update with ID: " + knownObjectId,
+ verbose("Got object to update with ID: " + knownResourceId,
collectionObject, CollectionObject.class);
// Update the content of this resource.
- //collectionObject.setCsid("updated-" + knownObjectId);
- collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber());
- collectionObject.setObjectName("updated-" + collectionObject.getObjectName());
+ collectionObject.setObjectNumber("updated-" +
+ collectionObject.getObjectNumber());
+ collectionObject.setObjectName("updated-" +
+ collectionObject.getObjectName());
// Submit the request to the service and store the response.
- res = client.update(knownObjectId, collectionObject);
+ res = client.update(knownResourceId, collectionObject);
int statusCode = res.getStatus();
- CollectionObject updatedObject = res.getEntity();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("update: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Check the contents of the response: does it match what was submitted?
+ // Check the contents of the response: does it match
+ // what was submitted?
+ CollectionObject updatedObject = res.getEntity();
verbose("update: ", updatedObject, CollectionObject.class);
Assert.assertEquals(updatedObject.getObjectName(),
collectionObject.getObjectName(),
// Failure outcomes
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void updateWithMalformedXml() {}
public void updateWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
+ String url = getResourceURL(knownResourceId);
+ final String entity = MALFORMED_XML_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
- final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class.
+ String url = getResourceURL(knownResourceId);
+ final String entity = WRONG_XML_SCHEMA_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in update(), below.
- CollectionObject collectionObject = createCollectionObject(NON_EXISTENT_ID);
+ CollectionObject collectionObject = createCollectionObjectInstance(NON_EXISTENT_ID);
ClientResponse<CollectionObject> res =
client.update(NON_EXISTENT_ID, collectionObject);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupDelete();
// Submit the request to the service and store the response.
- ClientResponse<Response> res = client.delete(knownObjectId);
+ ClientResponse<Response> res = client.delete(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("delete: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("deleteNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownObjectId);
+ String url = getResourceURL(knownResourceId);
int statusCode = submitRequest(method, url);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
return SERVICE_PATH_COMPONENT;
}
- private CollectionObject createCollectionObject(String identifier) {
+ private CollectionObject createCollectionObjectInstance(String identifier) {
CollectionObject collectionObject =
- createCollectionObject(
+ createCollectionObjectInstance(
"objectNumber-" + identifier,
"objectName-" + identifier);
return collectionObject;
}
- private CollectionObject createCollectionObject(String objectNumber, String objectName) {
+ private CollectionObject createCollectionObjectInstance(
+ String objectNumber, String objectName) {
CollectionObject collectionObject = new CollectionObject();
collectionObject.setObjectNumber(objectNumber);
collectionObject.setObjectName(objectName);
* IntakeServiceTest, carries out tests against a
* deployed and running Intake Service.
*
- * $LastChangedRevision: 511 $
- * $LastChangedDate: 2009-08-06 20:16:16 +0000 (Thu, 06 Aug 2009) $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class IntakeServiceTest extends AbstractServiceTest {
// Instance variables specific to this test.
private IntakeClient client = new IntakeClient();
final String SERVICE_PATH_COMPONENT = "intakes";
- private String knownObjectId = null;
+ private String knownResourceId = null;
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
String identifier = createIdentifier();
- Intake intake = createIntake(identifier);
+ Intake intake = createIntakeInstance(identifier);
ClientResponse<Response> res = client.create(intake);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
//
+ // Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
verbose("create: status = " + statusCode);
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation for additional tests below.
- knownObjectId = extractId(res);
+ // Store the ID returned from this create operation for
+ // additional tests below.
+ knownResourceId = extractId(res);
}
@Override
// Failure outcomes
@Override
- @Test(dependsOnMethods = {"create"}, expectedExceptions = IllegalArgumentException.class)
+ @Test(dependsOnMethods = {"create"},
+ expectedExceptions = IllegalArgumentException.class)
public void createNull() {
ClientResponse<Response> res = client.create(null);
}
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void createWithMalformedXml() {}
public void createWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
String url = getServiceRootURL();
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
final String entity = WRONG_XML_SCHEMA_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupRead();
// Submit the request to the service and store the response.
- ClientResponse<Intake> res = client.read(knownObjectId);
+ ClientResponse<Intake> res = client.read(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("read: status = " + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
ClientResponse<Intake> res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
IntakeList list = res.getEntity();
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readList: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
list.getIntakeListItem();
int i = 0;
for(IntakeList.IntakeListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" + item.getCsid());
- verbose("readList: list-item[" + i + "] objectNumber=" + item.getEntryNumber());
- verbose("readList: list-item[" + i + "] URI=" + item.getUri());
+ verbose("readList: list-item[" + i + "] csid=" +
+ item.getCsid());
+ verbose("readList: list-item[" + i + "] objectNumber=" +
+ item.getEntryNumber());
+ verbose("readList: list-item[" + i + "] URI=" +
+ item.getUri());
i++;
}
}
setupUpdate();
// Retrieve an existing resource that we can update.
- ClientResponse<Intake> res = client.read(knownObjectId);
+ ClientResponse<Intake> res = client.read(knownResourceId);
verbose("read: status = " + res.getStatus());
Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
Intake intake = res.getEntity();
- verbose("Got object to update with ID: " + knownObjectId,
+ verbose("Got object to update with ID: " + knownResourceId,
intake, Intake.class);
// Update the content of this resource.
intake.setEntryDate("updated-" + intake.getEntryDate());
// Submit the request to the service and store the response.
- res = client.update(knownObjectId, intake);
+ res = client.update(knownResourceId, intake);
int statusCode = res.getStatus();
Intake updatedObject = res.getEntity();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("update: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Check the contents of the response: does it match what was submitted?
+ // Check the contents of the response: does it match
+ // what was submitted?
verbose("update: ", updatedObject, Intake.class);
Assert.assertEquals(updatedObject.getEntryDate(),
intake.getEntryDate(),
// Failure outcomes
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void updateWithMalformedXml() {}
public void updateWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
+ String url = getResourceURL(knownResourceId);
+ final String entity = MALFORMED_XML_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
- final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class.
+ String url = getResourceURL(knownResourceId);
+ final String entity = WRONG_XML_SCHEMA_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in update(), below.
- Intake intake = createIntake(NON_EXISTENT_ID);
+ Intake intake = createIntakeInstance(NON_EXISTENT_ID);
ClientResponse<Intake> res =
client.update(NON_EXISTENT_ID, intake);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupDelete();
// Submit the request to the service and store the response.
- ClientResponse<Response> res = client.delete(knownObjectId);
+ ClientResponse<Response> res = client.delete(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("delete: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("deleteNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownObjectId);
+ String url = getResourceURL(knownResourceId);
int statusCode = submitRequest(method, url);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
public String getServicePathComponent() {
- // @TODO Determine if it is possible to obtain this
- // value programmatically.
- //
- // We set this in an annotation in the CollectionObjectProxy
- // interface, for instance. We also set service-specific
- // constants in each service module, which might also
- // return this value.
return SERVICE_PATH_COMPONENT;
}
- private Intake createIntake(String identifier) {
+ private Intake createIntakeInstance(String identifier) {
Intake intake =
- createIntake(
+ createIntakeInstance(
"entryNumber-" + identifier,
"entryDate-" + identifier);
return intake;
}
- private Intake createIntake(String entryNumber, String entryDate) {
+ private Intake createIntakeInstance(String entryNumber, String entryDate) {
Intake intake = new Intake();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright © 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.collectionspace.services.client.test;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;
-import org.collectionspace.services.common.relation.RelationJAXBSchema;
-
/**
- * A RelationNuxeoServiceTest.
+ * RelationServiceTest, carries out tests against a
+ * deployed and running Relation Service.
*
- * @version $Revision:$
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class RelationServiceTest extends AbstractServiceTest {
private RelationClient client = new RelationClient();
final String SERVICE_PATH_COMPONENT = "relations";
- private String knownObjectId = null;
+ private String knownResourceId = null;
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
setupCreate();
// Submit the request to the service and store the response.
- Relation relation = new Relation();
String identifier = createIdentifier();
- fillRelation(relation, identifier);
+ Relation relation = createRelationInstance(identifier);
ClientResponse<Response> res = client.create(relation);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
//
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation for additional tests below.
- knownObjectId = extractId(res);
+ // Store the ID returned from this create operation for
+ // additional tests below.
+ knownResourceId = extractId(res);
}
@Override
// Failure outcomes
@Override
- @Test(dependsOnMethods = {"create"}, expectedExceptions = IllegalArgumentException.class)
+ @Test(dependsOnMethods = {"create"},
+ expectedExceptions = IllegalArgumentException.class)
public void createNull() {
ClientResponse<Response> res = client.create(null);
}
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void createWithMalformedXml() {}
public void createWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
String url = getServiceRootURL();
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
final String entity = WRONG_XML_SCHEMA_DATA;
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupRead();
// Submit the request to the service and store the response.
- ClientResponse<Relation> res = client.read(knownObjectId);
+ ClientResponse<Relation> res = client.read(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("read: status = " + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ // Verify that the resource identifier
Relation returnedRelation = res.getEntity();
- Assert.assertEquals(returnedRelation.getCsid(), knownObjectId);
+ Assert.assertEquals(returnedRelation.getCsid(), knownResourceId);
}
ClientResponse<Relation> res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
RelationList list = res.getEntity();
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("readList: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
list.getRelationListItem();
int i = 0;
for(RelationList.RelationListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" + item.getCsid());
- verbose("readList: list-item[" + i + "] URI=" + item.getUri());
+ verbose("readList: list-item[" + i + "] csid=" +
+ item.getCsid());
+ verbose("readList: list-item[" + i + "] URI=" +
+ item.getUri());
i++;
}
}
setupUpdate();
// Retrieve an existing resource that we can update.
- ClientResponse<Relation> res = client.read(knownObjectId);
+ ClientResponse<Relation> res = client.read(knownResourceId);
verbose("read: status = " + res.getStatus());
Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
Relation relation = res.getEntity();
- verbose("Got object to update with ID: " + knownObjectId,
+ verbose("Got object to update with ID: " + knownResourceId,
relation, Relation.class);
// Update the content of this resource.
relation.setDocumentType2("updated-" + relation.getDocumentType2());
// Submit the request to the service and store the response.
- res = client.update(knownObjectId, relation);
+ res = client.update(knownResourceId, relation);
int statusCode = res.getStatus();
Relation updatedObject = res.getEntity();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("update: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Check the contents of the response: does it match what was submitted?
+ // Check the contents of the response: does it match
+ // what was submitted?
verbose("update: ", updatedObject, Relation.class);
- final String msg = "Data in updated object did not match submitted data.";
+ final String msg =
+ "Data in updated object did not match submitted data.";
Assert.assertEquals(
updatedObject.getDocumentId1(), relation.getDocumentId1(), msg);
Assert.assertEquals(
// Failure outcomes
- // Placeholders until the two tests below can be uncommented. See Issue CSPACE-401.
+ // Placeholders until the two tests below can be uncommented.
+ // See Issue CSPACE-401.
public void updateWithMalformedXml() {}
public void updateWithWrongXmlSchema() {}
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
+ String url = getResourceURL(knownResourceId);
final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownObjectId);
+ String url = getResourceURL(knownResourceId);
final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class.
int statusCode = submitRequest(method, url, entity);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupUpdateNonExistent();
// Submit the request to the service and store the response.
- // Note: The ID used in this 'fill' call may be arbitrary.
+ // Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in update(), below.
- Relation relation = new Relation();
- fillRelation(relation, NON_EXISTENT_ID);
+ Relation relation = createRelationInstance(NON_EXISTENT_ID);
ClientResponse<Relation> res =
client.update(NON_EXISTENT_ID, relation);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("updateNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
setupDelete();
// Submit the request to the service and store the response.
- String relationID = this.createEntity("0");
- Assert.assertNotNull(relationID, "Could not create a new object to delete.");
- ClientResponse<Response> res = client.delete(relationID);
+ ClientResponse<Response> res = client.delete(knownResourceId);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- verbose("delete: status = " + res.getStatus() + " csid = " + relationID);
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ verbose("delete: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("deleteNonExistent: status = " + res.getStatus());
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownObjectId);
+ String url = getResourceURL(knownResourceId);
int statusCode = submitRequest(method, url);
- // Check the status code of the response: does it match the expected response(s)?
+ // Check the status code of the response: does it match
+ // the expected response(s)?
verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
return SERVICE_PATH_COMPONENT;
}
- private String createEntity(String identifier) {
-
+ private Relation createRelationInstance(String identifier) {
String result = null;
-
Relation relation = new Relation();
fillRelation(relation, identifier);
- ClientResponse<Response> res = client.create(relation);
- Assert.assertEquals(res.getStatus(), Response.Status.CREATED.getStatusCode());
-
- result = extractId(res);
- String responseString = res.toString();
- System.out.println(responseString);
-
- return result;
+ return relation;
}
/**
}
/**
- * Creates the relation.
+ * Fills the relation.
*
* @param documentId1 the document id1
* @param documentType1 the document type1