Changeset 3452 for DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
- Timestamp:
- 08/21/13 09:47:33 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r3450 r3452 18 18 package eu.dasish.annotation.backend.rest; 19 19 20 import eu.dasish.annotation.backend.dao.DaoDispatcher; 20 21 import com.sun.jersey.api.client.GenericType; 22 import eu.dasish.annotation.backend.Helpers; 21 23 import eu.dasish.annotation.backend.TestBackendConstants; 22 24 import eu.dasish.annotation.backend.TestInstances; … … 24 26 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 25 27 import eu.dasish.annotation.schema.Annotation; 28 import eu.dasish.annotation.schema.ResourceREF; 26 29 import java.sql.SQLException; 27 30 import javax.xml.bind.JAXBElement; … … 35 38 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 36 39 import java.lang.InstantiationException; 40 import java.sql.Timestamp; 37 41 import javax.servlet.ServletException; 42 import javax.xml.datatype.DatatypeConfigurationException; 43 import org.junit.Ignore; 38 44 import org.springframework.mock.web.MockHttpServletRequest; 39 45 /** … … 43 49 44 50 @RunWith(value = SpringJUnit4ClassRunner.class) 45 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockDaoDispatcher.xml", 46 "/spring-test-config/mockery.xml", }) 51 @ContextConfiguration(locations = { "/spring-test-config/mockery.xml", "/spring-test-config/mockDaoDispatcher.xml", 52 "/spring-test-config/mockAnnotationDao.xml","/spring-test-config/mockUserDao.xml", "/spring-test-config/mockNotebookDao.xml", 53 "/spring-test-config/mockSourceDao.xml", "/spring-test-config/mockVersionDao.xml", "/spring-test-config/mockCachedRepresentationDao.xml"}) 47 54 public class AnnotationResourceTest { 48 55 … … 93 100 //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID); 94 101 102 final int[] mockDelete = new int[4]; 103 mockDelete[0]=1; // # deleted annotations 104 mockDelete[3]=1; // # deleted annotation_prinipal_permissions 105 mockDelete[2]=2; // # deleted annotations_target_sources, (5,3), (5,4) 106 mockDelete[3]=1; // # deletd sources, 4 95 107 mockery.checking(new Expectations() { 96 108 { … … 99 111 100 112 oneOf(daoDispatcher).deleteAnnotation(5); 101 will(returnValue( 1));113 will(returnValue(mockDelete)); 102 114 } 103 115 }); … … 111 123 */ 112 124 @Test 113 public void testCreateAnnotation() throws SQLException, InstantiationException, IllegalAccessException, ServletException {125 public void testCreateAnnotation() throws SQLException, InstantiationException, IllegalAccessException, ServletException, DatatypeConfigurationException { 114 126 System.out.println("test createAnnotation"); 115 127 final Annotation annotationToAdd = new GenericType<Annotation>(){}.getRawClass().newInstance(); … … 121 133 // Number newAnnotationID = daoDispatcher.addUsersAnnotation(annotation, userID); 122 134 // Annotation newAnnotation = daoDispatcher.getAnnotation(newAnnotationID); 135 final String ownerString = "5"; 136 final Number ownerID = 5; 137 final Number newAnnotationID = 6; 138 final Annotation addedAnnotation = annotationToAdd; 139 ResourceREF owner = new ResourceREF(); 140 owner.setRef(ownerString); 141 addedAnnotation.setOwner(owner); 142 addedAnnotation.setURI((new AnnotationIdentifier()).toString()); 123 143 144 addedAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000"))); 124 145 mockery.checking(new Expectations() { 125 146 { 126 147 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UserIdentifier.class))); 127 will(returnValue( 5));148 will(returnValue(ownerID)); 128 149 129 oneOf(daoDispatcher).addUsersAnnotation(annotationToAdd, 5); 130 will(returnValue(1)); 150 oneOf(daoDispatcher).addUsersAnnotation(annotationToAdd, ownerID); 151 will(returnValue(newAnnotationID)); 152 153 oneOf(daoDispatcher).getAnnotation(newAnnotationID); 154 will(returnValue(addedAnnotation)); 131 155 } 132 156 }); … … 139 163 140 164 JAXBElement<Annotation> result = annotationResource.createAnnotation(annotationToAdd); 141 assertEquals(String.valueOf(5), result.getValue().getOwner().getRef()); 142 assertFalse(null == result.getValue().getURI()); 165 assertEquals(addedAnnotation.getOwner().getRef(), result.getValue().getOwner().getRef()); 166 assertEquals(addedAnnotation.getURI(), result.getValue().getURI()); 167 assertEquals(addedAnnotation.getHeadline(), result.getValue().getHeadline()); 168 assertEquals(addedAnnotation.getPermissions(), result.getValue().getPermissions()); 169 assertEquals(addedAnnotation.getTargetSources(), result.getValue().getTargetSources()); 170 assertEquals(addedAnnotation.getTimeStamp(), result.getValue().getTimeStamp()); 171 assertEquals(addedAnnotation.getBody(), result.getValue().getBody()); 143 172 144 173 }
Note: See TracChangeset
for help on using the changeset viewer.