Ignore:
Timestamp:
02/06/14 12:21:44 (10 years ago)
Author:
olhsha
Message:

Unit test HSQL database is cleaned up (obsolete rows are removed), UNit tests are refactored (hairy code is removed, a lot of test backend constants). Existed unit tests work.

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

    r4429 r4461  
    8080    public AnnotationResourceTest() {
    8181        mockRequest = new MockHttpServletRequest();
    82         mockRequest.setRemoteUser("twan");
     82        mockRequest.setRemoteUser("olhsha@mpi.nl");
    8383       
    8484    }
     
    9191    public void testGetAnnotation() throws SQLException, JAXBException, Exception {
    9292        System.out.println("getAnnotation");
    93         final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT;
     93        final String externalIDstring= "00000000-0000-0000-0000-000000000021";
    9494        final Annotation expectedAnnotation = (new TestInstances(TestBackendConstants._TEST_SERVLET_URI)).getAnnotationOne();       
    9595        annotationResource.setHttpServletRequest(mockRequest);       
     
    107107                will(doAll());
    108108               
    109                 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("twan");
     109                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
    110110                will(returnValue(3));
    111111               
     
    139139        mockDelete[0]=1; // # deleted annotations
    140140        mockDelete[3]=1; // # deleted annotation_prinipal_permissions
    141         mockDelete[2]=2; // # deleted  annotations_target_Targets, (5,3), (5,4)
     141        mockDelete[2]=2; // # deleted  annotations_target_Targets, (4,3), (4,4)
    142142        mockDelete[3]=1; // # deletd Targets, 4
    143143       
     
    151151               
    152152             
    153                 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("twan");
    154                 will(returnValue(5));
     153                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
     154                will(returnValue(3));
    155155               
    156156                oneOf(mockDbIntegrityService).setServiceURI(with(any(String.class)));
     
    158158               
    159159                oneOf(mockDbIntegrityService).getAnnotationInternalIdentifier(with(aNonNull(UUID.class)));             
    160                 will(returnValue(5));
    161                
    162                
    163                 oneOf(mockDbIntegrityService).getAnnotationOwner(5);
    164                 will(returnValue(5)); 
    165                
    166                 oneOf(mockDbIntegrityService).deleteAnnotation(5);
     160                will(returnValue(4));
     161               
     162               
     163                oneOf(mockDbIntegrityService).getAnnotationOwner(4);
     164                will(returnValue(3)); 
     165               
     166                oneOf(mockDbIntegrityService).deleteAnnotation(4);
    167167                will(returnValue(mockDelete));
    168168            }
     
    170170       
    171171       
    172         String result = annotationResource.deleteAnnotation(TestBackendConstants._TEST_ANNOT_5_EXT);
     172        String result = annotationResource.deleteAnnotation("00000000-0000-0000-0000-000000000024");
    173173        assertEquals("1 annotation(s) deleted.", result);
    174174    }
     
    187187        annotationToAdd.setTargets(TargetInfoList);
    188188        annotationToAdd.setOwnerRef(null);     
    189         annotationToAdd.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP));
     189        annotationToAdd.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"));
    190190        annotationToAdd.setHeadline("headline");
    191191        annotationToAdd.setTargets(TargetInfoList);
     
    209209        final Annotation addedAnnotation = (new ObjectFactory()).createAnnotation(annotationToAdd).getValue();
    210210        addedAnnotation.setURI("http://localhost:8080/annotator-backend/api/annotations/"+UUID.randomUUID().toString());
    211         addedAnnotation.setOwnerRef("http://localhost:8080/annotator-backend/api/users/"+TestBackendConstants._TEST_USER_3_EXT_ID);
     211        addedAnnotation.setOwnerRef("http://localhost:8080/annotator-backend/api/users/"+"00000000-0000-0000-0000-000000000111");
    212212     
    213213        annotationResource.setHttpServletRequest(mockRequest);
     
    223223                will(doAll());
    224224               
    225                 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("twan");
     225                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
    226226                will(returnValue(3));
    227227               
Note: See TracChangeset for help on using the changeset viewer.