You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hise-commits@incubator.apache.org by ut...@apache.org on 2010/09/09 15:03:59 UTC

svn commit: r995452 [5/5] - in /incubator/hise/trunk: ./ hise-fe/ hise-fe/src/ hise-fe/src/main/ hise-fe/src/main/java/ hise-fe/src/main/java/org/ hise-fe/src/main/java/org/apache/ hise-fe/src/main/java/org/apache/hise/ hise-fe/src/main/java/org/apache...

Added: incubator/hise/trunk/hise-ws-client/src/main/resources/wsdls/xml.xsd
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-ws-client/src/main/resources/wsdls/xml.xsd?rev=995452&view=auto
==============================================================================
--- incubator/hise/trunk/hise-ws-client/src/main/resources/wsdls/xml.xsd (added)
+++ incubator/hise/trunk/hise-ws-client/src/main/resources/wsdls/xml.xsd Thu Sep  9 15:03:55 2010
@@ -0,0 +1,145 @@
+<?xml version='1.0'?>
+<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
+
+ <xs:annotation>
+  <xs:documentation>
+   See http://www.w3.org/XML/1998/namespace.html and
+   http://www.w3.org/TR/REC-xml for information about this namespace.
+
+    This schema document describes the XML namespace, in a form
+    suitable for import by other schema documents.  
+
+    Note that local names in this namespace are intended to be defined
+    only by the World Wide Web Consortium or its subgroups.  The
+    following names are currently defined in this namespace and should
+    not be used with conflicting semantics by any Working Group,
+    specification, or document instance:
+
+    base (as an attribute name): denotes an attribute whose value
+         provides a URI to be used as the base for interpreting any
+         relative URIs in the scope of the element on which it
+         appears; its value is inherited.  This name is reserved
+         by virtue of its definition in the XML Base specification.
+
+    id   (as an attribute name): denotes an attribute whose value
+         should be interpreted as if declared to be of type ID.
+         This name is reserved by virtue of its definition in the
+         xml:id specification.
+
+    lang (as an attribute name): denotes an attribute whose value
+         is a language code for the natural language of the content of
+         any element; its value is inherited.  This name is reserved
+         by virtue of its definition in the XML specification.
+  
+    space (as an attribute name): denotes an attribute whose
+         value is a keyword indicating what whitespace processing
+         discipline is intended for the content of the element; its
+         value is inherited.  This name is reserved by virtue of its
+         definition in the XML specification.
+
+    Father (in any context at all): denotes Jon Bosak, the chair of 
+         the original XML Working Group.  This name is reserved by 
+         the following decision of the W3C XML Plenary and 
+         XML Coordination groups:
+
+             In appreciation for his vision, leadership and dedication
+             the W3C XML Plenary on this 10th day of February, 2000
+             reserves for Jon Bosak in perpetuity the XML name
+             xml:Father
+  </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+  <xs:documentation>This schema defines attributes and an attribute group
+        suitable for use by
+        schemas wishing to allow xml:base, xml:lang, xml:space or xml:id
+        attributes on elements they define.
+
+        To enable this, such a schema must import this schema
+        for the XML namespace, e.g. as follows:
+        &lt;schema . . .>
+         . . .
+         &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+                    schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+        Subsequently, qualified reference to any of the attributes
+        or the group defined below will have the desired effect, e.g.
+
+        &lt;type . . .>
+         . . .
+         &lt;attributeGroup ref="xml:specialAttrs"/>
+ 
+         will define a type which will schema-validate an instance
+         element with any of those attributes</xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+  <xs:documentation>In keeping with the XML Schema WG's standard versioning
+   policy, this schema document will persist at
+   http://www.w3.org/2007/08/xml.xsd.
+   At the date of issue it can also be found at
+   http://www.w3.org/2001/xml.xsd.
+   The schema document at that URI may however change in the future,
+   in order to remain compatible with the latest version of XML Schema
+   itself, or with the XML namespace itself.  In other words, if the XML
+   Schema or XML namespaces change, the version of this document at
+   http://www.w3.org/2001/xml.xsd will change
+   accordingly; the version at
+   http://www.w3.org/2007/08/xml.xsd will not change.
+  </xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="lang">
+  <xs:annotation>
+   <xs:documentation>Attempting to install the relevant ISO 2- and 3-letter
+         codes as the enumerated possible values is probably never
+         going to be a realistic possibility.  See
+         RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry
+         at http://www.iana.org/assignments/lang-tag-apps.htm for
+         further information.
+
+         The union allows for the 'un-declaration' of xml:lang with
+         the empty string.</xs:documentation>
+  </xs:annotation>
+  <xs:simpleType>
+   <xs:union memberTypes="xs:language">
+    <xs:simpleType>    
+     <xs:restriction base="xs:string">
+      <xs:enumeration value=""/>
+     </xs:restriction>
+    </xs:simpleType>
+   </xs:union>
+  </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="space">
+  <xs:simpleType>
+   <xs:restriction base="xs:NCName">
+    <xs:enumeration value="default"/>
+    <xs:enumeration value="preserve"/>
+   </xs:restriction>
+  </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="base" type="xs:anyURI">
+  <xs:annotation>
+   <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
+                     information about this attribute.</xs:documentation>
+  </xs:annotation>
+ </xs:attribute>
+ 
+ <xs:attribute name="id" type="xs:ID">
+  <xs:annotation>
+   <xs:documentation>See http://www.w3.org/TR/xml-id/ for
+                     information about this attribute.</xs:documentation>
+  </xs:annotation>
+ </xs:attribute>
+
+ <xs:attributeGroup name="specialAttrs">
+  <xs:attribute ref="xml:base"/>
+  <xs:attribute ref="xml:lang"/>
+  <xs:attribute ref="xml:space"/>
+  <xs:attribute ref="xml:id"/>
+ </xs:attributeGroup>
+
+</xs:schema>

Added: incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/facade/HiseApiFacadeUnitTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/facade/HiseApiFacadeUnitTest.java?rev=995452&view=auto
==============================================================================
--- incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/facade/HiseApiFacadeUnitTest.java (added)
+++ incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/facade/HiseApiFacadeUnitTest.java Thu Sep  9 15:03:55 2010
@@ -0,0 +1,127 @@
+package org.apache.hise.api.client.facade;
+
+import static junit.framework.Assert.assertEquals;
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hise.model.ws.TStatus;
+import org.apache.hise.model.ws.TTask;
+import org.apache.hise.ws.IllegalArgumentFault;
+import org.apache.hise.ws.IllegalStateFault;
+import org.apache.hise.ws.TaskOperationsInterface;
+import org.apache.hise.wsclient.facade.FilterCriteria;
+import org.apache.hise.wsclient.facade.HiseApiFacade;
+import org.apache.hise.wsclient.facade.HiseApiFacadeImpl;
+import org.apache.hise.wsclient.infrastructure.TaskConverter;
+import org.apache.hise.wsclient.infrastructure.Tasks;
+import org.apache.hise.wsclient.infrastructure.WSSecurityInterceptor;
+import org.apache.hise.wsclient.model.Task;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class HiseApiFacadeUnitTest {
+
+	private static String USER = "testuser";
+    private static String PASSWORD = "test";    
+    
+    @Mock
+	private WSSecurityInterceptor wsSecurityInterceptor;
+
+    @Mock
+	private TaskOperationsInterface hiseInterface;
+	
+	@Test
+    public void getMyTasksShouldReturnCorrectTasks() throws IllegalArgumentFault, IllegalStateFault {
+    	//given
+		List<TTask> wsTasks = buildTasks(15);
+    	HiseApiFacade hiseApiFacade = buildHiseApiFacade();
+    	
+    	when(hiseInterface.getMyTasks(eq("ALL"), anyString(), anyString(), anyListOf(TStatus.class), 
+    			anyString(), anyString(), eq(Tasks.MAX_TASKS))).thenReturn(wsTasks);
+    	
+    	//when
+    	List<Task> tasks = hiseApiFacade.getMyTasks(USER, PASSWORD, new FilterCriteria());
+    	 
+    	//then
+    	assertEquals(wsTasks.size(), tasks.size());
+    	for (int i = 0; i < tasks.size(); i++) {
+    		assertEquals(wsTasks.get(i).getId(), tasks.get(i).getId());
+    	}
+    }
+	
+	@Test
+    public void getMyTasksShouldFilterOutWrongPriority() throws IllegalArgumentFault, IllegalStateFault {
+    	//given
+		List<TTask> wsTasks = buildTasks(15);
+    	HiseApiFacade hiseApiFacade = buildHiseApiFacade();
+    	
+    	when(hiseInterface.getMyTasks(eq("ALL"), anyString(), anyString(), anyListOf(TStatus.class), 
+    			anyString(), anyString(), eq(Tasks.MAX_TASKS))).thenReturn(wsTasks);
+    	
+    	FilterCriteria fc = new FilterCriteria();
+    	fc.setPriority(2);
+    	
+    	//when
+    	
+		List<Task> tasks = hiseApiFacade.getMyTasks(USER, PASSWORD, fc);
+    	 
+    	//then
+    	assertEquals(0, tasks.size());
+    }
+	
+	
+	@Test
+    public void getTaskShouldReturnCorrectTasks() throws IllegalArgumentFault, IllegalStateFault {
+    	//given
+		String taskId = "5";
+		TTask wsTask = buildTask(5);
+    	HiseApiFacade hiseApiFacade = buildHiseApiFacade();
+    	when(hiseInterface.getTaskInfo(taskId)).thenReturn(wsTask);
+    	
+    	//when
+    	Task task = hiseApiFacade.getTask(USER, PASSWORD, taskId);
+    	 
+    	//then
+    	verify(hiseInterface).getTaskInfo(taskId);
+    	assertEquals(wsTask.getId(), task.getId());
+    }
+
+    private HiseApiFacade buildHiseApiFacade() {
+    	HiseApiFacadeImpl hiseApiFacade = new HiseApiFacadeImpl();
+    	hiseApiFacade.setService(hiseInterface);
+    	hiseApiFacade.setWssInterceptor(wsSecurityInterceptor);
+    	hiseApiFacade.setTaskConverter(new TaskConverter());
+    	return hiseApiFacade;
+    }
+
+    private List<TTask> buildTasks(int count) {
+        List<TTask> tasks = new ArrayList<TTask>();
+    	for (int i = 0; i < count; i++) {
+        	tasks.add(buildTask(i));
+        }
+        return tasks;
+    }
+
+    private TTask buildTask(int id) {
+        return buildTask(Integer.toString(id));
+    }
+    
+    private TTask buildTask(String id) {
+        TTask task = new TTask();
+        task.setId(id);
+        task.setStatus(TStatus.CREATED);
+        task.setPriority(BigInteger.valueOf(1l));
+        return task;
+    }
+}

Added: incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/infrastucture/TaskConverterUnitTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/infrastucture/TaskConverterUnitTest.java?rev=995452&view=auto
==============================================================================
--- incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/infrastucture/TaskConverterUnitTest.java (added)
+++ incubator/hise/trunk/hise-ws-client/src/test/java/org/apache/hise/api/client/infrastucture/TaskConverterUnitTest.java Thu Sep  9 15:03:55 2010
@@ -0,0 +1,110 @@
+package org.apache.hise.api.client.infrastucture;
+
+import java.math.BigInteger;
+
+import org.apache.hise.model.htd.TOrganizationalEntity;
+import org.apache.hise.model.ws.TStatus;
+import org.apache.hise.model.ws.TTask;
+import org.apache.hise.wsclient.infrastructure.TaskConverter;
+import org.apache.hise.wsclient.model.Task;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class TaskConverterUnitTest {
+
+	@Test
+	public void testBuildTaskDtoDoesntFailForEmptyTask() {
+		//given
+		TaskConverter factory = new TaskConverter();
+		TTask wsTask = new TTask();
+		wsTask.setStatus(TStatus.COMPLETED);
+		
+		//when
+		Task task = factory.buildTask(wsTask);
+		
+		//then
+		Assert.assertNotNull(task);
+	}
+	
+	@Test
+	public void testBuildTaskDtoSetsAllData() {
+		//given
+		TaskConverter factory = new TaskConverter();
+		TTask wsTask = createFilledTask(12);
+		
+		//when
+		Task task = factory.buildTask(wsTask);
+		
+		//then
+		assertIfEqual(wsTask, task);
+	}
+	
+	private void assertIfEqual(TTask wsTask, Task task) {
+		if (wsTask == null) {
+			Assert.assertNull(task);
+		} else {
+			Assert.assertEquals(wsTask.getActualOwner(), task.getActualOwner());
+			Assert.assertEquals(wsTask.getCreatedBy(), task.getCreatedBy());
+			Assert.assertEquals(wsTask.getId(), task.getId());
+			Assert.assertEquals(wsTask.getPresentationName(), task.getPresentationName());
+			Assert.assertEquals(wsTask.getPresentationSubject(), task.getPresentationSubject());
+			Assert.assertEquals(wsTask.getPrimarySearchBy(), task.getPrimarySearchBy());
+			Assert.assertEquals(wsTask.getTaskInitiator(), task.getTaskInitiator());
+			Assert.assertEquals(wsTask.getTaskType(), task.getTaskType());
+			Assert.assertEquals(wsTask.getStatus().name(), task.getStatus().name());
+			Assert.assertEquals(wsTask.getPriority().intValue(), task.getPriority().intValue());
+			Assert.assertEquals(wsTask.isCompleteByExists(), task.getCompleteByExists());
+			Assert.assertEquals(wsTask.isEscalated(), task.getEscalated());
+			Assert.assertEquals(wsTask.isHasAttachments(), task.getHasAttachments());
+			Assert.assertEquals(wsTask.isHasComments(), task.getHasComments());
+			Assert.assertEquals(wsTask.isHasFault(), task.getHasFault());
+			Assert.assertEquals(wsTask.isHasOutput(), task.getHasOutput());
+			Assert.assertEquals(wsTask.isHasPotentialOwners(), task.getHasPotentialOwners());
+			Assert.assertEquals(wsTask.isIsSkipable(), task.getIsSkipable());
+			Assert.assertEquals(wsTask.isRenderingMethodExists(), task.getRenderingMethodExists());
+			Assert.assertEquals(wsTask.isStartByExists(), task.getStartByExists());
+		}
+		
+	}
+
+	private TTask createFilledTask(int id) {
+		TTask task = new TTask();
+		task.setActualOwner("owner");
+		task.setBusinessAdministrators(new TOrganizationalEntity());
+		task.setCompleteByExists(randomBoolean());
+		task.setCreatedBy("someone");
+		task.setEscalated(randomBoolean());
+		task.setHasAttachments(randomBoolean());
+		task.setHasComments(randomBoolean());
+		task.setHasFault(randomBoolean());
+		task.setHasOutput(randomBoolean());
+		task.setHasPotentialOwners(randomBoolean());
+		task.setId(Integer.toString(id));
+		task.setIsSkipable(randomBoolean());
+		task.setNotificationRecipients(new TOrganizationalEntity());
+		task.setPotentialOwners(new TOrganizationalEntity());
+		task.setPresentationName("task name");
+		task.setPresentationSubject("task Subject");
+		task.setPrimarySearchBy("search");
+		task.setPriority(new BigInteger("3"));
+		task.setRenderingMethodExists(randomBoolean());
+		task.setStartByExists(randomBoolean());
+		task.setStatus(randomStatus());	
+		task.setTaskInitiator("initiator");
+		task.setTaskStakeholders(new TOrganizationalEntity());
+		task.setTaskType("task type");		
+		return task;
+	}
+	
+	private boolean randomBoolean() {
+		return Math.random() < 0.5;
+	}
+	
+	private TStatus randomStatus() {
+		int index = (int) Math.floor(Math.random() * TStatus.values().length);
+		return TStatus.values()[index];
+	}
+	
+}

Modified: incubator/hise/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/pom.xml?rev=995452&r1=995451&r2=995452&view=diff
==============================================================================
--- incubator/hise/trunk/pom.xml (original)
+++ incubator/hise/trunk/pom.xml Thu Sep  9 15:03:55 2010
@@ -33,6 +33,8 @@
         <module>hise-web</module>
         <module>hise-bundle</module>
         <module>hise-karaf</module>
+        <module>hise-ws-client</module>
+        <module>hise-fe</module>
 	</modules>
 	<properties>
 		<cxf.version>2.2.6</cxf.version>