mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Minor changes in the getclassdetail webscript and changes in unit test
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11739 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -6,31 +6,43 @@
|
|||||||
</#if>
|
</#if>
|
||||||
<#if assocdefs.title?exists>
|
<#if assocdefs.title?exists>
|
||||||
"title" : "${assocdefs.title}",
|
"title" : "${assocdefs.title}",
|
||||||
|
<#else>
|
||||||
|
"title" : "",
|
||||||
</#if>
|
</#if>
|
||||||
<#if assocdefs.description?exists>
|
<#if assocdefs.description?exists>
|
||||||
"description" : "${assocdefs.description}",
|
"description" : "${assocdefs.description}",
|
||||||
|
<#else>
|
||||||
|
"description" : "",
|
||||||
</#if>
|
</#if>
|
||||||
<#if assocdefs.isChild() == true>
|
<#if assocdefs.isChild() == true>
|
||||||
"isChild" : true,
|
"isChildAssociation" : true,
|
||||||
<#else>
|
<#else>
|
||||||
"isChild" : false,
|
"isChildAssociation" : false,
|
||||||
</#if>
|
</#if>
|
||||||
<#if assocdefs.isProtected() == true>
|
<#if assocdefs.isProtected() == true>
|
||||||
"protected" : true,
|
"protected" : true,
|
||||||
<#else>
|
<#else>
|
||||||
"protected" : false,
|
"protected" : false,
|
||||||
</#if>
|
</#if>
|
||||||
"source" :
|
"source" : {
|
||||||
{
|
<#if assocdefs.getSourceClass().name?exists>
|
||||||
"class" : "${assocdefs.getSourceClass().name.toPrefixString()}",
|
"class" : "${assocdefs.getSourceClass().name.toPrefixString()}",
|
||||||
"isSourceMandatory" : ${assocdefs.isSourceMandatory()?string},
|
</#if>
|
||||||
"isSourceMany" : ${assocdefs.isSourceMany()?string}
|
<#if assocdefs.getSourceRoleName()?exists>
|
||||||
|
"role" : "${assocdefs.getSourceRoleName().toPrefixString()}",
|
||||||
|
</#if>
|
||||||
|
"mandatory" : ${assocdefs.isSourceMandatory()?string},
|
||||||
|
"many" : ${assocdefs.isSourceMany()?string}
|
||||||
},
|
},
|
||||||
"target" :
|
"target" : {
|
||||||
{
|
<#if assocdefs.getTargetClass().name?exists>
|
||||||
"class" : "${assocdefs.getTargetClass().name.toPrefixString()}",
|
"class" : "${assocdefs.getTargetClass().name.toPrefixString()}",
|
||||||
"isTargetMandatory" : ${assocdefs.isTargetMandatory()?string},
|
</#if>
|
||||||
"isTargetMany" : ${assocdefs.isTargetMany()?string}
|
<#if assocdefs.getTargetRoleName()?exists>
|
||||||
|
"role" : "${assocdefs.getTargetRoleName().toPrefixString()}",
|
||||||
|
</#if>
|
||||||
|
"mandatory" : ${assocdefs.isTargetMandatory()?string},
|
||||||
|
"many" : ${assocdefs.isTargetMany()?string}
|
||||||
},
|
},
|
||||||
<#if assocdefs.isChild() == true>
|
<#if assocdefs.isChild() == true>
|
||||||
"url" : "${"/api/classes/" + url.templateArgs.classname + "/childassociation/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
"url" : "${"/api/classes/" + url.templateArgs.classname + "/childassociation/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||||
|
@@ -11,9 +11,13 @@
|
|||||||
</#if>
|
</#if>
|
||||||
<#if classdefs.title?exists>
|
<#if classdefs.title?exists>
|
||||||
"title" : "${classdefs.title}",
|
"title" : "${classdefs.title}",
|
||||||
|
<#else>
|
||||||
|
"title" : "",
|
||||||
</#if>
|
</#if>
|
||||||
<#if classdefs.description?exists>
|
<#if classdefs.description?exists>
|
||||||
"description" : "${classdefs.description}",
|
"description" : "${classdefs.description}",
|
||||||
|
<#else>
|
||||||
|
"description" : "",
|
||||||
</#if>
|
</#if>
|
||||||
"parent" : {
|
"parent" : {
|
||||||
<#if classdefs.parentName?exists>
|
<#if classdefs.parentName?exists>
|
||||||
@@ -24,14 +28,14 @@
|
|||||||
},
|
},
|
||||||
"defaultAspects" : {
|
"defaultAspects" : {
|
||||||
<#if classdefs.defaultAspects?exists>
|
<#if classdefs.defaultAspects?exists>
|
||||||
<#list classdefs.defaultAspects as aspectdefs>
|
<#list classdefs.defaultAspects as aspectdef>
|
||||||
"${aspectdefs.name.toPrefixString()}" : {
|
"${aspectdef.name.toPrefixString()}" : {
|
||||||
"name" : "${aspectdefs.name}",
|
"name" : "${aspectdef.name.toPrefixString()}",
|
||||||
<#if aspectdefs.title?exists>
|
<#if aspectdef.title?exists>
|
||||||
"title" : "${aspectdefs.title}",
|
"title" : "${aspectdef.title}",
|
||||||
</#if>
|
</#if>
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + aspectdefs.name.toPrefixString()?replace(":","_")}"
|
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + aspectdef.name.toPrefixString()?replace(":","_")}"
|
||||||
}<#if aspectdefs_has_next>,</#if>
|
}<#if aspectdef_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
},
|
},
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>Get Class Definitions</shortname>
|
<shortname>Get Class Definitions</shortname>
|
||||||
<description>Get the collection of class definitions </description>
|
<description>Get the collection of class definitions - parameters classfilter , namespaceprefix and name</description>
|
||||||
<url>/api/classes?cf={classFilter?}&nsp={namespacePrefix?}&n={name?}</url>
|
<url>/api/classes?cf={classFilter?}&nsp={namespacePrefix?}&n={name?}</url>
|
||||||
<format default="json"/>
|
<format default="json"/>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
|
@@ -32,9 +32,11 @@ import java.util.Map;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Unit Test for Dictionaryervice
|
*
|
||||||
|
* Unit Test for Dictionaryervice REST API
|
||||||
* @author Saravanan Sellathurai
|
* @author Saravanan Sellathurai
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DictionaryServiceTest extends BaseWebScriptTest
|
public class DictionaryServiceTest extends BaseWebScriptTest
|
||||||
@@ -52,12 +54,9 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
|||||||
{
|
{
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
//TODO individual check of all elements
|
|
||||||
public void testGetPropertyDef() throws Exception
|
private boolean validatePropertyDef(JSONObject result) throws Exception
|
||||||
{
|
{
|
||||||
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/property/cm_created"), 200);
|
|
||||||
assertEquals(200,response.getStatus());
|
|
||||||
JSONObject result = new JSONObject(response.getContentAsString());
|
|
||||||
assertEquals("cm:created", result.get("name"));
|
assertEquals("cm:created", result.get("name"));
|
||||||
assertEquals("Created Date", result.get("title"));
|
assertEquals("Created Date", result.get("title"));
|
||||||
assertEquals("Created Date", result.get("description"));
|
assertEquals("Created Date", result.get("description"));
|
||||||
@@ -68,106 +67,399 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals(true, result.get("protected"));
|
assertEquals(true, result.get("protected"));
|
||||||
assertEquals(true, result.get("indexed"));
|
assertEquals(true, result.get("indexed"));
|
||||||
assertEquals(true, result.get("indexedAtomically"));
|
assertEquals(true, result.get("indexedAtomically"));
|
||||||
response = sendRequest(new GetRequest("/api/classes/cm_hi/property/cm_welcome"), 404);
|
//assertEquals check is yet to be made on constraints
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals("/api/classes/cm_auditable/property/cm_created", result.get("url"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateAssociationDef(JSONObject result) throws Exception
|
||||||
|
{
|
||||||
|
assertEquals("cm:avatar", result.get("name"));
|
||||||
|
assertEquals("", result.get("title"));
|
||||||
|
assertEquals("", result.get("description"));
|
||||||
|
assertEquals(false, result.get("isChildAssociation"));
|
||||||
|
assertEquals(false, result.get("protected"));
|
||||||
|
|
||||||
|
assertEquals("cm:person", result.getJSONObject("source").get("class"));
|
||||||
|
assertEquals("cm:avatarOf", result.getJSONObject("source").get("role"));
|
||||||
|
assertEquals(false, result.getJSONObject("source").get("mandatory"));
|
||||||
|
assertEquals(false, result.getJSONObject("source").get("many"));
|
||||||
|
|
||||||
|
assertEquals("cm:content", result.getJSONObject("target").get("class"));
|
||||||
|
assertEquals("cm:hasAvatar", result.getJSONObject("target").get("role"));
|
||||||
|
assertEquals(false, result.getJSONObject("target").get("mandatory"));
|
||||||
|
assertEquals(false, result.getJSONObject("target").get("many"));
|
||||||
|
|
||||||
|
assertEquals("/api/classes/cm_person/association/cm_avatar", result.get("url"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateTypeClass(JSONObject result) throws Exception
|
||||||
|
{
|
||||||
|
//cm:cmobject is of type =>type
|
||||||
|
assertEquals("cm:cmobject", result.get("name"));
|
||||||
|
assertEquals(false , result.get("isAspect"));
|
||||||
|
assertEquals("Object", result.get("title"));
|
||||||
|
assertEquals("", result.get("description"));
|
||||||
|
|
||||||
|
assertEquals("sys:base", result.getJSONObject("parent").get("name"));
|
||||||
|
assertEquals("base", result.getJSONObject("parent").get("title"));
|
||||||
|
assertEquals("/api/classes/sys_base", result.getJSONObject("parent").get("url"));
|
||||||
|
|
||||||
|
assertEquals("sys:referenceable", result.getJSONObject("defaultAspects").getJSONObject("sys:referenceable").get("name"));
|
||||||
|
assertEquals("Referenceable", result.getJSONObject("defaultAspects").getJSONObject("sys:referenceable").get("title"));
|
||||||
|
assertEquals("/api/classes/cm_cmobject/property/sys_referenceable", result.getJSONObject("defaultAspects").getJSONObject("sys:referenceable").get("url"));
|
||||||
|
|
||||||
|
assertEquals("cm:auditable", result.getJSONObject("defaultAspects").getJSONObject("cm:auditable").get("name"));
|
||||||
|
assertEquals("Auditable", result.getJSONObject("defaultAspects").getJSONObject("cm:auditable").get("title"));
|
||||||
|
assertEquals("/api/classes/cm_cmobject/property/cm_auditable", result.getJSONObject("defaultAspects").getJSONObject("cm:auditable").get("url"));
|
||||||
|
|
||||||
|
assertEquals("cm:name", result.getJSONObject("properties").getJSONObject("cm:name").get("name"));
|
||||||
|
assertEquals("Name", result.getJSONObject("properties").getJSONObject("cm:name").get("title"));
|
||||||
|
assertEquals("/api/classes/cm_cmobject/property/cm_name", result.getJSONObject("properties").getJSONObject("cm:name").get("url"));
|
||||||
|
|
||||||
|
assertEquals(0, result.getJSONObject("associations").length());
|
||||||
|
assertEquals(0, result.getJSONObject("childassociations").length());
|
||||||
|
|
||||||
|
assertEquals("/api/classes/cm_cmobject", result.get("url"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateAspectClass(JSONObject result) throws Exception
|
||||||
|
{
|
||||||
|
//cm:thumbnailed is of type =>aspect
|
||||||
|
assertEquals("cm:thumbnailed", result.get("name"));
|
||||||
|
assertEquals(true , result.get("isAspect"));
|
||||||
|
assertEquals("Thumbnailed", result.get("title"));
|
||||||
|
assertEquals("", result.get("description"));
|
||||||
|
assertEquals(0, result.getJSONObject("parent").length());
|
||||||
|
assertEquals(0, result.getJSONObject("defaultAspects").length());
|
||||||
|
|
||||||
|
assertEquals("cm:automaticUpdate", result.getJSONObject("properties").getJSONObject("cm:automaticUpdate").get("name"));
|
||||||
|
assertEquals("Automatic Update", result.getJSONObject("properties").getJSONObject("cm:automaticUpdate").get("title"));
|
||||||
|
assertEquals("/api/classes/cm_thumbnailed/property/cm_automaticUpdate", result.getJSONObject("properties").getJSONObject("cm:automaticUpdate").get("url"));
|
||||||
|
|
||||||
|
assertEquals(0, result.getJSONObject("associations").length());
|
||||||
|
|
||||||
|
assertEquals("cm:thumbnails", result.getJSONObject("childassociations").getJSONObject("cm:thumbnails").get("name"));
|
||||||
|
assertEquals("/api/classes/cm_thumbnailed/childassociation/cm_thumbnails", result.getJSONObject("childassociations").getJSONObject("cm:thumbnails").get("url"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testGetPropertyDef() throws Exception
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/property/cm_created"), 200);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
JSONObject result = new JSONObject(response.getContentAsString());
|
||||||
|
assertEquals(true, validatePropertyDef(result));
|
||||||
|
// TODO Constraint data has to be added... yet to do
|
||||||
|
assertEquals(13, result.length());
|
||||||
|
response = sendRequest(new GetRequest("/api/classes/cm_hi/property/cm_welcome"), 404);
|
||||||
|
assertEquals(404,response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO individual check of all elements
|
|
||||||
public void testGetPropertyDefs() throws Exception
|
public void testGetPropertyDefs() throws Exception
|
||||||
{
|
{
|
||||||
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/properties"), 200);
|
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/properties"), 200);
|
||||||
|
JSONArray result = new JSONArray(response.getContentAsString());
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if(result.getJSONObject(i).get("name").equals("cm:created"))
|
||||||
|
assertEquals(true, validatePropertyDef(result.getJSONObject(i)));
|
||||||
|
}
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
assertEquals(5, result.length());
|
||||||
response = sendRequest(new GetRequest("/api/classes/cm_welcome/properties"), 404);
|
response = sendRequest(new GetRequest("/api/classes/cm_welcome/properties"), 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO individual check of all elements
|
|
||||||
public void testGetClassDetail() throws Exception
|
public void testGetClassDetail() throws Exception
|
||||||
{
|
{
|
||||||
GetRequest req = new GetRequest(URL_SITES + "/cm_auditable");
|
GetRequest req = new GetRequest(URL_SITES + "/cm_thumbnailed");
|
||||||
Response response = sendRequest(req, 200);
|
Response response = sendRequest(req, 200);
|
||||||
|
JSONObject result = new JSONObject(response.getContentAsString());
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
response = sendRequest(new GetRequest("/api/classes/cmsara_hi"), 404);
|
assertEquals(true, validateAspectClass(result));
|
||||||
|
|
||||||
|
req = new GetRequest(URL_SITES + "/cm_cmobject");
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONObject(response.getContentAsString());
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
assertEquals(true, validateTypeClass(result));
|
||||||
|
|
||||||
|
response = sendRequest(new GetRequest("/api/classes/cm_hi"), 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO individual check of all elements
|
|
||||||
|
|
||||||
public void testGetClassDetails() throws Exception
|
public void testGetClassDetails() throws Exception
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* There are seven scenarios with getting class details , all are optional fields
|
||||||
|
* Classfilter namespaceprefix name Returns
|
||||||
|
* 1 yes yes yes single class
|
||||||
|
* 2 yes yes no Array of classes [returns array of classes of the particular namespaceprefix]
|
||||||
|
* 3 yes no no Array of classes [depends on classfilter, either type or aspect or all classes in the repo]
|
||||||
|
* 4 no no no Array of classes [returns all classes of both type and aspects in the entire repository]
|
||||||
|
* 5 no yes yes single class [returns a single class of a valid namespaceprefix:name combination]
|
||||||
|
* 6 no yes no Array of classes [returns an array of all aspects and types under particular namespaceprefix]
|
||||||
|
* 7 no no yes Array of all classes [since name alone doesn't makes any meaning]
|
||||||
|
*
|
||||||
|
* Test cases are provided for all the above scenarios
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//check for a aspect under cm with name thumbnailes [case-type:1]
|
||||||
GetRequest req = new GetRequest(URL_SITES);
|
GetRequest req = new GetRequest(URL_SITES);
|
||||||
Map< String, String > arguments = new HashMap< String, String >();
|
Map< String, String > arguments = new HashMap< String, String >();
|
||||||
arguments.put("cf", "aspect");
|
arguments.put("cf", "aspect");
|
||||||
arguments.put("nsp", "cm");
|
arguments.put("nsp", "cm");
|
||||||
arguments.put("n", "dublincore");
|
arguments.put("n", "thumbnailed");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
Response response = sendRequest(req, 200);
|
Response response = sendRequest(req, 200);
|
||||||
|
JSONArray result = new JSONArray(response.getContentAsString());
|
||||||
|
boolean flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all aspects under cm without option=>name
|
//check for a type under cm with name cmobject [case-type:1]
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "type");
|
arguments.put("cf", "type");
|
||||||
arguments.put("nsp", "wca");
|
arguments.put("nsp", "cm");
|
||||||
arguments.put("n", "rendition");
|
arguments.put("n", "cmobject");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all aspects under cm without option=>name
|
//check for a type under cm with name cmobject [case-type:1]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("cf", "all");
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
arguments.put("n", "cmobject");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a type under cm without options=>name, namespaceprefix [case-type:2]
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "type");
|
arguments.put("cf", "type");
|
||||||
arguments.put("nsp", "wca");
|
arguments.put("nsp", "cm");
|
||||||
arguments.put("n", "rendition");
|
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
// the above result has all the types under cm, so now check for the presence type cm:cmobject in the array of classes of all types
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all aspects under cm without option=>name
|
//check for a aspect under cm without options=>name [case-type:2]
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "aspect");
|
arguments.put("cf", "aspect");
|
||||||
arguments.put("nsp", "cm");
|
arguments.put("nsp", "cm");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
// the above result has all the aspects under cm, so now check for the presence aspect cm:thumnailed in the array of classes of all aspects
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all types under cm without option=>name
|
|
||||||
|
//check for all aspects under cm without options=>name [case-type:2]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("cf", "all");
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for all type under cm without options=>name, namespaceprefix [case-type:3]
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "type");
|
arguments.put("cf", "type");
|
||||||
arguments.put("nsp", "cm");
|
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all data under cm without option=>name
|
//check for all aspect under cm without options=>name, namespaceprefix [case-type:3]
|
||||||
arguments.clear();
|
|
||||||
arguments.put("cf", "all");
|
|
||||||
arguments.put("nsp", "cm");
|
|
||||||
req.setArgs(arguments);
|
|
||||||
response = sendRequest(req, 200);
|
|
||||||
assertEquals(200,response.getStatus());
|
|
||||||
|
|
||||||
//check for all dictionary data without option=>name and option=>namespaceprefix
|
|
||||||
arguments.clear();
|
|
||||||
arguments.put("cf", "all");
|
|
||||||
req.setArgs(arguments);
|
|
||||||
response = sendRequest(req, 200);
|
|
||||||
assertEquals(200,response.getStatus());
|
|
||||||
|
|
||||||
//check for all aspect dictionary data without option=>name and option=>namespaceprefix
|
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "aspect");
|
arguments.put("cf", "aspect");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
//check for all types dictionary data without option=>name and option=>namespaceprefix
|
//check for all aspect and type in the repository when nothing is given [case-type:4]
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "type");
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for all aspect and type in the repository when nothing is given [case-type:4]
|
||||||
|
arguments.clear();
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a classname [namespaceprefix:name => cm:cmobject] without classfilter option [case-type:5]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
arguments.put("n", "cmobject");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 200);
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a classname [namespaceprefix:name => cm:thumbnailed] without classfilter option [case-type:5]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
arguments.put("n", "cmobject");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a namespaceprefix [namespaceprefix => cm] without classfilter and name option [case-type:6]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a namespaceprefix [namespaceprefix => cm] without classfilter and name option [case-type:6]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a namespaceprefix [namespaceprefix => cm] without classfilter and name option [case-type:6]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("nsp", "cm");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a name alone without classfilter and namespaceprefix option [case-type:7]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("n", "cmobject");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:cmobject")) flag = validateTypeClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
|
//check for a name alone without classfilter and namespaceprefix option [case-type:7]
|
||||||
|
arguments.clear();
|
||||||
|
arguments.put("n", "thumbnailed");
|
||||||
|
req.setArgs(arguments);
|
||||||
|
response = sendRequest(req, 200);
|
||||||
|
result = new JSONArray(response.getContentAsString());
|
||||||
|
flag = false;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed")) flag = validateAspectClass(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true , flag);
|
||||||
|
assertEquals(200,response.getStatus());
|
||||||
|
|
||||||
// Test with wrong data
|
// Test with wrong data
|
||||||
//check for all aspects under cm without option=>name
|
//check for all aspects under cm without option=>name
|
||||||
@@ -196,7 +488,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
//check for all dictionary data without option=>name and option=>namespaceprefix
|
//check for all dictionary data without option=>name and option=>namespaceprefix
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "allsara");
|
arguments.put("cf", "a<EFBFBD>&llsara");
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 404);
|
response = sendRequest(req, 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
@@ -215,11 +507,9 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
|||||||
response = sendRequest(req, 404);
|
response = sendRequest(req, 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
|
|
||||||
//check for aspects under cm with an invalid name dublincoresara
|
//check with an invalid namespaceprefix
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
arguments.put("cf", "aspectss");
|
|
||||||
arguments.put("nsp", "cmsd");
|
arguments.put("nsp", "cmsd");
|
||||||
arguments.put("n", "dublincoresara");
|
|
||||||
req.setArgs(arguments);
|
req.setArgs(arguments);
|
||||||
response = sendRequest(req, 404);
|
response = sendRequest(req, 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
@@ -231,26 +521,31 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals(200,response.getStatus());
|
assertEquals(200,response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO individual check of all elements
|
|
||||||
|
|
||||||
public void testGetAssociatoinDef() throws Exception
|
public void testGetAssociatoinDef() throws Exception
|
||||||
{
|
{
|
||||||
GetRequest req = new GetRequest(URL_SITES + "/cm_person/association/cm_avatar");
|
GetRequest req = new GetRequest(URL_SITES + "/cm_person/association/cm_avatar");
|
||||||
Response response = sendRequest(req, 200);
|
Response response = sendRequest(req, 200);
|
||||||
JSONObject result = new JSONObject(response.getContentAsString());
|
JSONObject result = new JSONObject(response.getContentAsString());
|
||||||
assertEquals("cm:avatar", result.get("name"));
|
assertEquals(true, validateAssociationDef(result));
|
||||||
assertEquals(false, result.get("isChild"));
|
|
||||||
assertEquals(false, result.get("protected"));
|
|
||||||
assertEquals(200,response.getStatus());
|
|
||||||
response = sendRequest(new GetRequest(URL_SITES +"/cm_personalbe/association/cms_avatarsara"), 404);
|
response = sendRequest(new GetRequest(URL_SITES +"/cm_personalbe/association/cms_avatarsara"), 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO individual check of all elements
|
|
||||||
public void testGetAssociatoinDefs() throws Exception
|
public void testGetAssociatoinDefs() throws Exception
|
||||||
{
|
{
|
||||||
GetRequest req = new GetRequest(URL_SITES + "/cm_person/associations");
|
GetRequest req = new GetRequest(URL_SITES + "/cm_person/associations");
|
||||||
Response response = sendRequest(req, 200);
|
Response response = sendRequest(req, 200);
|
||||||
assertEquals(200,response.getStatus());
|
JSONArray result = new JSONArray(response.getContentAsString());
|
||||||
|
boolean flag = true;
|
||||||
|
for(int i=0; i<result.length(); i++)
|
||||||
|
{
|
||||||
|
if(result.getJSONObject(i).get("name").equals("cm:avatar"))
|
||||||
|
flag = validateAssociationDef(result.getJSONObject(i));
|
||||||
|
}
|
||||||
|
assertEquals(true, flag);
|
||||||
|
assertEquals(1,result.length());
|
||||||
response = sendRequest(new GetRequest(URL_SITES +"/cmsa_personalbe/associations"), 404);
|
response = sendRequest(new GetRequest(URL_SITES +"/cmsa_personalbe/associations"), 404);
|
||||||
assertEquals(404,response.getStatus());
|
assertEquals(404,response.getStatus());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user