Changeset 4461


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.

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDao.java

    r4281 r4461  
    116116        String emailCriterion = user.getEMail().toLowerCase();
    117117        StringBuilder sqlTargets = new StringBuilder("SELECT ");
    118         sqlTargets.append(principal_id).append(" FROM ").append(principalTableName).append(" WHERE ").append(e_mail).append("= ? LIMIT 1");
     118        sqlTargets.append(principal_id).append(" FROM ").append(principalTableName).append(" WHERE ").append("LOWER(").append(e_mail).append(")= ? LIMIT 1");
    119119        List<Number> resultTargets = getSimpleJdbcTemplate().query(sqlTargets.toString(), principalIDRowMapper, emailCriterion);
    120120        if (resultTargets.size() > 0) {
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/sql/DashishAnnotatorCreate.sql

    r4429 r4461  
    5252    external_id text UNIQUE NOT NULL,
    5353    owner_id integer REFERENCES principal(principal_id),
    54     last_modified timestamp default current_timestamp AT TIME ZONE 'UTC',
     54    last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
    5555    title text
    5656);
     
    6161    external_id text UNIQUE NOT NULL,
    6262    owner_id integer REFERENCES principal(principal_id),
    63     last_modified timestamp default current_timestamp AT TIME ZONE 'UTC',
     63    last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
    6464    headline text,
    6565    body_text text,
     
    7373    target_id SERIAL UNIQUE NOT NULL,
    7474    external_id text UNIQUE NOT NULL,
    75     last_modified timestamp default current_timestamp AT TIME ZONE 'UTC',
     75    last_modified timestamp default (current_timestamp AT TIME ZONE 'UTC'),
    7676    link_uri text,
    7777    version text,
     
    8585    tool text,
    8686    type_ text,
    87     file_ blob
     87    file_ bytea
    8888);
    8989
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java

    r4181 r4461  
    2525public class TestBackendConstants {
    2626   
    27     public static final String _TEST_NOTEBOOK_1_EXT_ID ="00000000-0000-0000-0000-000000000001";
    28     public static final String _TEST_NOTEBOOK_2_EXT_ID ="00000000-0000-0000-0000-000000000002";
    29     public static final String _TEST_UID_1_ = "00000000-0000-0000-0000-000000000003";
    30     public static final String _TEST_UID_2_ = "00000000-0000-0000-0000-000000000004";
    31     public static final String _TEST_AID_1_ =  "00000000-0000-0000-0000-000000000005";
    32     public static final String _TEST_NULL_UUID_ = "00000000-0000-0000-0000-000000000006";
    33    
    34     // testing jdbcAnnotationDao
    35     public static final String _TEST_NOTEBOOK_3_EXT = "00000000-0000-0000-0000-000000000011";
    36     public static final String _TEST_NOTEBOOK_4_EXT = "00000000-0000-0000-0000-000000000012";
    37     public static final String _TEST_NOTEBOOK_5_EXT = "00000000-0000-0000-0000-000000000013";
    38    
    39     public static final String _TEST_NOTEBOOK_3_TITLE = "Notebook 3";
    40     public static final String _TEST_NOTEBOOK_4_TITLE = "Notebook 4";
    41     public static final String _TEST_NOTEBOOK_5_TITLE = "Notebook 5";
    42    
    43     public static final String _TEST_ANNOT_2_EXT = "00000000-0000-0000-0000-000000000021";
    44     public static final String _TEST_ANNOT_3_EXT = "00000000-0000-0000-0000-000000000022";
    45     public static final String _TEST_ANNOT_4_EXT = "00000000-0000-0000-0000-000000000023";
    46     public static final String _TEST_ANNOT_5_EXT  = "00000000-0000-0000-0000-000000000024";
    47     public static final String _TEST_ANNOT_7_EXT_NOT_IN_DB = "00000000-0000-0000-0000-000000000026";
    48    
    49     public static final String _TEST_ANNOT_2_HEADLINE = "Sagrada Famiglia";
    50     public static final String _TEST_ANNOT_3_HEADLINE = "Gaudi";
    51     public static final String _TEST_ANNOT_4_HEADLINE = "Art Nuveau";
    52     public static final String _TEST_ANNOT_TO_ADD_HEADLINE = "Annotation to add to test DAO";
    53    
    54     public static final String _TEST_BODY_MIMETYPE_HTML = "text/html";
    55     public static final String _TEST_BODY_MIMETYPE_TEXT = "text/plain";
    56    
    57     public static final int _TEST_ANNOT_2_OWNER = 3;
    58     public static final int _TEST_ANNOT_3_OWNER = 4;
    59     public static final int _TEST_ANNOT_4_OWNER = 5;
    60    
    61     public static final String _TEST_ANNOT_2_BODY = "<html><body>some html 1</body></html>";
    62     public static final String _TEST_ANNOT_TO_ADD_BODY = "<html><body>the stuff to be added</body></html>";
    63    
    64     public static final String _TEST_ANNOT_2_TIME_STAMP = "2013-08-12T09:25:00.383000Z";
    65    
    66     public static final String annotaiontoDeleteInDB="INSERT INTO annotation (annotation_id, owner_id,headline,body_text, body_mimetype, external_id) VALUES (25, 111, 'Annotation to delete','<html><body>some html 4</body></html>', 'text/html', 00000000-0000-0000-0000-000000000025');";
    67    
    68     public static final String _TEST_USER_3_EXT_ID = "00000000-0000-0000-0000-000000000111";
    69     public static final String _TEST_USER_4_EXT_ID = "00000000-0000-0000-0000-000000000112"; 
    70     public static final String _TEST_USER_5_EXT_ID = "00000000-0000-0000-0000-000000000113"; 
    71    
    72     public static final String _TEST_USER_XXX_EXT_ID = "00000000-0000-0000-0000-000000000666";
    73    
    74    
    75     public static final String _TEST_Target_1_EXT_ID = "00000000-0000-0000-0000-000000000031";
    76     public static final String _TEST_Target_2_EXT_ID = "00000000-0000-0000-0000-000000000032";
    77    
    78     public static final String _TEST_Target_1_LINK = "http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia";
    79     public static final String _TEST_Target_2_LINK = "http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD";
    80    
    81      public static final String _TEST_Target_1_FRAGMENT = "de_Opdracht";
    82    
    83    
    84     public static final String _TEST_Target_1_VERSION = "version 1.0";
    85     public static final String _TEST_Target_2_VERSION = "version 1.0";
    86    
    87     public static final String _TEST_CACHED_REPRESENTATION_1_EXT_ID_ = "00000000-0000-0000-0000-000000000051";
    88     public static final String _TEST_CACHED_REPRESENTATION_1_MIME_TYPE_ =  "text/html";
    89     public static final String _TEST_CACHED_REPRESENTATION_1_TOOL_ =  "latex";
    90     public static final String _TEST_CACHED_REPRESENTATION_1_TYPE_ =  "text";
    91     public static final int _TEST_CACHED_REPRESENTATION_1_BLOB_BYTE_1 =  16;
    92     public static final int _TEST_CACHED_REPRESENTATION_1_BLOB_BYTE_2 =  1;
    93    
    94    
    95     public static final String _TEST_TEMP_Target_ID = "Barcelona-1";
    96     public static final String _TEST_ANNOT_TO_ADD_NEW_Target_BODY = "refers to "+_TEST_TEMP_Target_ID;
    97     public static final String _TEST_ANNOT_TO_ADD_NEW_Target_HEADLINE = "SF in Catalan";
    98     public static final String _TEST_NEW_Target_LINK = "http://www.sagradafamilia.cat/docs_instit/historia.php ";
    99    
    10027    public static final String _TEST_SERVLET_URI = "http://localhost:8080/annotator-backend/api/";
    10128    public static final String _TEST_SERVLET_URI_annotations = "http://localhost:8080/annotator-backend/api/annotations/";
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java

    r4276 r4461  
    4242   
    4343    private Annotation makeAnnotationOne(String baseURI){
    44         Annotation result = makeAnnotation(baseURI, TestBackendConstants._TEST_ANNOT_2_BODY, TestBackendConstants._TEST_BODY_MIMETYPE_HTML, TestBackendConstants._TEST_ANNOT_2_HEADLINE, TestBackendConstants._TEST_USER_3_EXT_ID);
     44        Annotation result = makeAnnotation(baseURI, "<html><body>some html 1</body></html>", "text/html", "Sagrada Famiglia", "00000000-0000-0000-0000-000000000111");
    4545        try {
    46         result.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP));
     46        result.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"));
    4747        } catch (DatatypeConfigurationException dce) {
    48             System.out.println("wrongly-formatted test timestamp "+TestBackendConstants._TEST_ANNOT_2_TIME_STAMP);
     48            System.out.println("wrongly-formatted test timestamp "+"2013-08-12T09:25:00.383000Z");
    4949            result.setLastModified(null);
    5050        }
     
    5353   
    5454    private Annotation makeAnnotationToAdd(String baseURI){
    55        Annotation result = makeAnnotation(baseURI, TestBackendConstants._TEST_ANNOT_TO_ADD_BODY, TestBackendConstants._TEST_BODY_MIMETYPE_TEXT, TestBackendConstants._TEST_ANNOT_TO_ADD_HEADLINE, TestBackendConstants._TEST_USER_3_EXT_ID);
     55       Annotation result = makeAnnotation(baseURI, "<html><body>some html 1</body></html>", "text/plain", "Annotation to add to test DAO", "00000000-0000-0000-0000-000000000111");
    5656       
    5757       TargetInfo TargetInfo =  new TargetInfo();
    58        TargetInfo.setLink(TestBackendConstants._TEST_Target_1_LINK);
    59        TargetInfo.setRef(TestBackendConstants._TEST_Target_1_EXT_ID);
    60        TargetInfo.setVersion(TestBackendConstants._TEST_Target_1_VERSION);
     58       TargetInfo.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia");
     59       TargetInfo.setRef("00000000-0000-0000-0000-000000000031");
     60       TargetInfo.setVersion("version 1.0");
    6161       
    6262       TargetInfoList targetInfos =  new TargetInfoList();
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java

    r4429 r4461  
    9191    public void testGetAnnotationInternalIdentifier() {
    9292        System.out.println("getAnnotationInternalIdentifier");
    93         final UUID externalID = UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT);
     93        final UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000021");
    9494
    9595        mockeryDao.checking(new Expectations() {
    9696            {
    9797                oneOf(annotationDao).getInternalID(externalID);
    98                 will(returnValue(2));
    99             }
    100         });
    101         assertEquals(2, dbIntegrityService.getAnnotationInternalIdentifier(externalID));
     98                will(returnValue(1));
     99            }
     100        });
     101        assertEquals(1, dbIntegrityService.getAnnotationInternalIdentifier(externalID));
    102102    }
    103103
     
    110110    public void testGetAnnotationExternalIdentifier() {
    111111        System.out.println("getAnnotationExternalIdentifier");
    112         final UUID externalID = UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT);
    113 
    114         mockeryDao.checking(new Expectations() {
    115             {
    116                 oneOf(annotationDao).getExternalID(2);
     112        final UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000021");
     113
     114        mockeryDao.checking(new Expectations() {
     115            {
     116                oneOf(annotationDao).getExternalID(1);
    117117                will(returnValue(externalID));
    118118            }
    119119        });
    120         assertEquals(TestBackendConstants._TEST_ANNOT_2_EXT, dbIntegrityService.getAnnotationExternalIdentifier(2).toString());
     120        assertEquals("00000000-0000-0000-0000-000000000021", dbIntegrityService.getAnnotationExternalIdentifier(1).toString());
    121121    }
    122122
     
    130130        System.out.println("getUserInternalIdentifier");
    131131
    132         final UUID externalID = UUID.fromString(TestBackendConstants._TEST_USER_5_EXT_ID);
     132        final UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000111");
    133133
    134134        mockeryDao.checking(new Expectations() {
    135135            {
    136136                oneOf(userDao).getInternalID(externalID);
    137                 will(returnValue(5));
    138             }
    139         });
    140         assertEquals(5, dbIntegrityService.getUserInternalIdentifier(externalID));
     137                will(returnValue(1));
     138            }
     139        });
     140        assertEquals(1, dbIntegrityService.getUserInternalIdentifier(externalID));
    141141    }
    142142
     
    149149    public void testGetUserExternalIdentifier() {
    150150        System.out.println("getUserExternalIdentifier");
    151         final UUID externalID = UUID.fromString(TestBackendConstants._TEST_USER_5_EXT_ID);
    152 
    153         mockeryDao.checking(new Expectations() {
    154             {
    155                 oneOf(userDao).getExternalID(5);
     151        final UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000111");
     152
     153        mockeryDao.checking(new Expectations() {
     154            {
     155                oneOf(userDao).getExternalID(1);
    156156                will(returnValue(externalID));
    157157            }
    158158        });
    159         assertEquals(TestBackendConstants._TEST_USER_5_EXT_ID, dbIntegrityService.getUserExternalIdentifier(5).toString());
     159        assertEquals("00000000-0000-0000-0000-000000000111", dbIntegrityService.getUserExternalIdentifier(1).toString());
    160160    }
    161161
     
    168168
    169169        final Annotation mockAnnotation = new Annotation();// corresponds to the annotation # 2
    170         mockAnnotation.setURI(TestBackendConstants._TEST_SERVLET_URI_annotations +TestBackendConstants._TEST_ANNOT_2_EXT);
    171         mockAnnotation.setHeadline(TestBackendConstants._TEST_ANNOT_2_HEADLINE);
    172         XMLGregorianCalendar mockTimeStamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP);
     170        mockAnnotation.setURI(TestBackendConstants._TEST_SERVLET_URI_annotations +"00000000-0000-0000-0000-000000000021");
     171        mockAnnotation.setHeadline("Sagrada Famiglia");
     172        XMLGregorianCalendar mockTimeStamp = DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z");
    173173        mockAnnotation.setLastModified(mockTimeStamp);
    174174        mockAnnotation.setOwnerRef("3");
     
    178178        mockBody.setTextBody(textBody);
    179179        textBody.setMimeType("text/plain");
    180         textBody.setBody(TestBackendConstants._TEST_ANNOT_2_BODY);
     180        textBody.setBody("<html><body>some html 1</body></html>");
    181181        mockAnnotation.setBody(mockBody);
    182182        mockAnnotation.setTargets(null);
     
    188188
    189189        final Target mockTargetOne = new Target();
    190         mockTargetOne.setLink(TestBackendConstants._TEST_Target_1_LINK);
    191         mockTargetOne.setURI(TestBackendConstants._TEST_SERVLET_URI_Targets +TestBackendConstants._TEST_Target_1_EXT_ID);
    192         mockTargetOne.setVersion(TestBackendConstants._TEST_Target_1_EXT_ID);
     190        mockTargetOne.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia");
     191        mockTargetOne.setURI(TestBackendConstants._TEST_SERVLET_URI_Targets +"00000000-0000-0000-0000-000000000031");
     192        mockTargetOne.setVersion("00000000-0000-0000-0000-000000000031");
    193193
    194194        final Target mockTargetTwo = new Target();
    195         mockTargetTwo.setLink(TestBackendConstants._TEST_Target_2_LINK);
    196         mockTargetTwo.setURI(TestBackendConstants._TEST_SERVLET_URI_Targets +TestBackendConstants._TEST_Target_2_EXT_ID);
    197         mockTargetTwo.setVersion(TestBackendConstants._TEST_Target_2_EXT_ID);
     195        mockTargetTwo.setLink("http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD");
     196        mockTargetTwo.setURI(TestBackendConstants._TEST_SERVLET_URI_Targets +"00000000-0000-0000-0000-000000000032");
     197        mockTargetTwo.setVersion("00000000-0000-0000-0000-000000000032");
    198198
    199199        final List<Map<Number, String>> listMap = new ArrayList<Map<Number, String>>();
     
    208208        listMap.add(map5);
    209209
    210         final String uri3 = TestBackendConstants._TEST_SERVLET_URI_users +TestBackendConstants._TEST_USER_3_EXT_ID;
    211         final String uri4 = TestBackendConstants._TEST_SERVLET_URI_users +TestBackendConstants._TEST_USER_4_EXT_ID;
    212         final String uri5 = TestBackendConstants._TEST_SERVLET_URI_users +TestBackendConstants._TEST_USER_5_EXT_ID;
     210        final String uri3 = TestBackendConstants._TEST_SERVLET_URI_users +"00000000-0000-0000-0000-000000000111";
     211        final String uri4 = TestBackendConstants._TEST_SERVLET_URI_users +"00000000-0000-0000-0000-000000000112";
     212        final String uri5 = TestBackendConstants._TEST_SERVLET_URI_users +"00000000-0000-0000-0000-000000000113";
    213213
    214214       
     
    250250
    251251        Annotation result = dbIntegrityService.getAnnotation(2);
    252         assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT, result.getURI());
     252        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021", result.getURI());
    253253        assertEquals("text/plain", result.getBody().getTextBody().getMimeType());
    254         assertEquals(TestBackendConstants._TEST_ANNOT_2_BODY, result.getBody().getTextBody().getBody());
    255         assertEquals(TestBackendConstants._TEST_ANNOT_2_HEADLINE, result.getHeadline());
    256         assertEquals(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP, result.getLastModified().toString());
    257         assertEquals(TestBackendConstants._TEST_SERVLET_URI_users+TestBackendConstants._TEST_USER_3_EXT_ID, result.getOwnerRef());
     254        assertEquals("<html><body>some html 1</body></html>", result.getBody().getTextBody().getBody());
     255        assertEquals("Sagrada Famiglia", result.getHeadline());
     256        assertEquals("2013-08-12T09:25:00.383000Z", result.getLastModified().toString());
     257        assertEquals(TestBackendConstants._TEST_SERVLET_URI_users+"00000000-0000-0000-0000-000000000111", result.getOwnerRef());
    258258
    259259        assertEquals(mockTargetOne.getLink(), result.getTargets().getTargetInfo().get(0).getLink());
     
    345345
    346346                oneOf(targetDao).getURIFromInternalID(1);
    347                 will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID));
     347                will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000031"));
    348348
    349349                oneOf(targetDao).getURIFromInternalID(2);
    350                 will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_2_EXT_ID));
     350                will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000032"));
    351351
    352352            }
     
    355355        ReferenceList result = dbIntegrityService.getAnnotationTargets(annotationID);
    356356        assertEquals(2, result.getRef().size());
    357         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID, result.getRef().get(0));
    358         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_2_EXT_ID, result.getRef().get(1));
     357        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000031", result.getRef().get(0));
     358        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000032", result.getRef().get(1));
    359359       
    360360    }
     
    392392
    393393        final String text = "some html";
    394         final UUID ownerUUID = UUID.fromString(TestBackendConstants._TEST_USER_4_EXT_ID);
     394        final UUID ownerUUID = UUID.fromString("00000000-0000-0000-0000-000000000112");
    395395        final String after = (new Timestamp(0)).toString();
    396396        final String before = (new Timestamp(System.currentTimeMillis())).toString();
     
    401401        final AnnotationInfo mockAnnotInfo = new AnnotationInfo();
    402402       
    403         mockAnnotInfo.setHeadline(TestBackendConstants._TEST_ANNOT_3_HEADLINE);       
    404         mockAnnotInfo.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations + TestBackendConstants._TEST_ANNOT_3_EXT);
     403        mockAnnotInfo.setHeadline("Gaudi");       
     404        mockAnnotInfo.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations + "00000000-0000-0000-0000-000000000022");
    405405       
    406406        final List<Number> TargetIDs = new ArrayList<Number>();
     
    451451               
    452452                oneOf(targetDao).getURIFromInternalID(2);
    453                 will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets +TestBackendConstants._TEST_Target_2_EXT_ID));
     453                will(returnValue(TestBackendConstants._TEST_SERVLET_URI_Targets +"00000000-0000-0000-0000-000000000032"));
    454454             
    455455               
     
    462462        AnnotationInfo resultAnnotInfo = result.getAnnotationInfo().get(0);
    463463        assertEquals(mockAnnotInfo.getHeadline(), resultAnnotInfo.getHeadline());
    464         assertEquals(TestBackendConstants._TEST_SERVLET_URI_users +TestBackendConstants._TEST_USER_4_EXT_ID, resultAnnotInfo.getOwnerRef());
     464        assertEquals(TestBackendConstants._TEST_SERVLET_URI_users +"00000000-0000-0000-0000-000000000112", resultAnnotInfo.getOwnerRef());
    465465        assertEquals(mockAnnotInfo.getRef(),result.getAnnotationInfo().get(0).getRef() );
    466         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets +TestBackendConstants._TEST_Target_2_EXT_ID, resultAnnotInfo.getTargets().getRef().get(0));
     466        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets +"00000000-0000-0000-0000-000000000032", resultAnnotInfo.getTargets().getRef().get(0));
    467467         
    468468    }
     
    585585        // test 1: adding an existing Target
    586586        TargetInfo testTargetOne = new TargetInfo();
    587         testTargetOne.setLink(TestBackendConstants._TEST_Target_1_LINK);
    588         testTargetOne.setRef(TestBackendConstants._TEST_SERVLET_URI_Targets + TestBackendConstants._TEST_Target_1_EXT_ID);
    589         testTargetOne.setVersion(TestBackendConstants._TEST_Target_2_VERSION );
     587        testTargetOne.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia");
     588        testTargetOne.setRef(TestBackendConstants._TEST_SERVLET_URI_Targets + "00000000-0000-0000-0000-000000000031");
     589        testTargetOne.setVersion("version 1.1");
    590590        final List<TargetInfo> mockTargetListOne = new ArrayList<TargetInfo>();
    591591        mockTargetListOne.add(testTargetOne);
     
    628628        final String tempTargetID = UUID.randomUUID().toString();
    629629        testTargetTwo.setRef(TestBackendConstants._TEST_SERVLET_URI_Targets + tempTargetID);
    630         testTargetTwo.setLink(TestBackendConstants._TEST_NEW_Target_LINK);
     630        testTargetTwo.setLink("http://www.sagradafamilia.cat/docs_instit/historia.php");
    631631        testTargetTwo.setVersion("version 1.0");
    632632        final List<TargetInfo> mockTargetListTwo = new ArrayList<TargetInfo>();
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java

    r4429 r4461  
    8484    public void testRetrieveTargetIDs() {
    8585        System.out.println("retrieveTargetIDs");
    86         Number annotationID = 2;
     86        Number annotationID = 1;
    8787        List<Number> result = jdbcAnnotationDao.retrieveTargetIDs(annotationID);
    8888        assertEquals(2, result.size());
     
    9595    public void testDeleteAllAnnotationTarget() throws SQLException{
    9696        System.out.println("test deleteAllAnnotationTargets");
    97         assertEquals(2, jdbcAnnotationDao.deleteAllAnnotationTarget(2));
    98         assertEquals(0, jdbcAnnotationDao.deleteAllAnnotationTarget(2));
     97        assertEquals(2, jdbcAnnotationDao.deleteAllAnnotationTarget(1));
     98        assertEquals(0, jdbcAnnotationDao.deleteAllAnnotationTarget(1));
    9999    }
    100100   
     
    103103    public void testDeleteAnnotationPrinciplePermissions() throws SQLException{
    104104        System.out.println("test deleteAllAnnotationTargets");
    105         int result = jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(2);
     105        int result = jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(1);
    106106        assertEquals(2, result);
    107         assertEquals(0, jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(2));
     107        assertEquals(0, jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(1));
    108108    }
    109109   
     
    112112    public void testAddAnnotationPrinciplePermission() throws SQLException{
    113113        System.out.println("test addAnnotationTargets");
    114         int result = jdbcAnnotationDao.addAnnotationPrincipalPermission(2, 1, Permission.READER);
     114        int result = jdbcAnnotationDao.addAnnotationPrincipalPermission(1, 1, Permission.READER);
    115115        assertEquals(1, result);
    116116    }
     
    120120    public void testAddAnnotationTarget() throws SQLException{
    121121        System.out.println("test addAnnotationTargetPair");
    122         assertEquals(1, jdbcAnnotationDao.addAnnotationTarget(1,2));
     122        assertEquals(1, jdbcAnnotationDao.addAnnotationTarget(1,3));
    123123    }
    124124   
     
    137137//        assertEquals(3, annotationInfos.size());
    138138//
    139 //        assertEquals(TestBackendConstants._TEST_ANNOT_2_HEADLINE, annotationInfos.get(0).getHeadline());
     139//        assertEquals("Sagrada Famiglia", annotationInfos.get(0).getHeadline());
    140140//        assertEquals(String.valueOf(TestBackendConstants._TEST_ANNOT_2_OWNER), annotationInfos.get(0).getOwnerRef());
    141 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations +TestBackendConstants._TEST_ANNOT_2_EXT,
     141//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations +"00000000-0000-0000-0000-000000000021",
    142142//           annotationInfos.get(0).getRef());         
    143143//        //assertEquals(TestBackendConstants._TEST_ANNOT_1_TARGETS, annotationInfos.get(0).getTargetTargets());
    144144//
    145 //        assertEquals(TestBackendConstants._TEST_ANNOT_3_HEADLINE, annotationInfos.get(1).getHeadline());
     145//        assertEquals("Gaudi", annotationInfos.get(1).getHeadline());
    146146//        assertEquals(String.valueOf(TestBackendConstants._TEST_ANNOT_3_OWNER), annotationInfos.get(1).getOwnerRef());
    147 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + TestBackendConstants._TEST_ANNOT_3_EXT,
     147//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + "00000000-0000-0000-0000-000000000022",
    148148//           annotationInfos.get(1).getRef());
    149149//        //assertEquals(TestBackendConstants._TEST_ANNOT_2_TARGETS, annotationInfos.get(1).getTargetTargets());
     
    151151//        assertEquals(TestBackendConstants._TEST_ANNOT_4_HEADLINE, annotationInfos.get(2).getHeadline());
    152152//        assertEquals(String.valueOf(TestBackendConstants._TEST_ANNOT_4_OWNER), annotationInfos.get(2).getOwnerRef());
    153 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + TestBackendConstants._TEST_ANNOT_4_EXT,
     153//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + "00000000-0000-0000-0000-000000000023",
    154154//           annotationInfos.get(2).getRef());
    155155//        //assertEquals(TestBackendConstants._TEST_ANNOT_3_TARGETS, annotationInfos.get(2).getTargetTargets());
     
    172172        System.out.println("getAnnotationREFs");
    173173        List<Number> annotIds = new ArrayList<Number>();
     174        annotIds.add(1);
    174175        annotIds.add(2);
    175176        annotIds.add(3);
    176         annotIds.add(4);
    177177
    178178        jdbcAnnotationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_annotations);
    179179        final List<String> testList = jdbcAnnotationDao.getAnnotationREFs(annotIds);
    180180        assertEquals(3, testList.size());
    181         assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT, testList.get(0));
    182         assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_3_EXT, testList.get(1));
    183         assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_4_EXT, testList.get(2));
     181        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021", testList.get(0));
     182        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000022", testList.get(1));
     183        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000023", testList.get(2));
    184184
    185185        final List<String> testListTwo = jdbcAnnotationDao.getAnnotationREFs(new ArrayList<Number>());
     
    200200        System.out.println("test getInternalID");
    201201
    202         final Number annotaionId = jdbcAnnotationDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT));
    203         assertEquals(2, annotaionId.intValue());
    204 
    205         final Number annotaionIdNE = jdbcAnnotationDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_ANNOT_7_EXT_NOT_IN_DB));
     202        final Number annotaionId = jdbcAnnotationDao.getInternalID(UUID.fromString("00000000-0000-0000-0000-000000000021"));
     203        assertEquals(1, annotaionId.intValue());
     204
     205        final Number annotaionIdNE = jdbcAnnotationDao.getInternalID(UUID.fromString("00000000-0000-0000-0000-0000000000cc"));
    206206        assertEquals(null, annotaionIdNE);
    207207
     
    217217        System.out.println("test getInternalIDFromURI");
    218218        jdbcAnnotationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_annotations);
    219         String uri = TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT;
     219        String uri = TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021";
    220220        Number result = jdbcAnnotationDao.getInternalIDFromURI(uri);
    221         assertEquals(2, result.intValue());
     221        assertEquals(1, result.intValue());
    222222    }
    223223
     
    231231        System.out.println("test getAnnotationWithoutTargets");
    232232        jdbcAnnotationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_annotations);
    233         final Annotation result= jdbcAnnotationDao.getAnnotationWithoutTargetsAndPermissions(2);
    234        
    235         assertEquals(TestBackendConstants._TEST_ANNOT_2_HEADLINE, result.getHeadline());
    236         assertEquals(TestBackendConstants._TEST_ANNOT_2_BODY, result.getBody().getTextBody().getBody());
    237         assertEquals(TestBackendConstants._TEST_BODY_MIMETYPE_HTML, result.getBody().getTextBody().getMimeType());
     233        final Annotation result= jdbcAnnotationDao.getAnnotationWithoutTargetsAndPermissions(1);
     234       
     235        assertEquals("Sagrada Famiglia", result.getHeadline());
     236        assertEquals("<html><body>some html 1</body></html>", result.getBody().getTextBody().getBody());
     237        assertEquals("text/html", result.getBody().getTextBody().getMimeType());
    238238        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+
    239                 TestBackendConstants._TEST_ANNOT_2_EXT, result.getURI());
    240         assertEquals(DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP), result.getLastModified());
     239                "00000000-0000-0000-0000-000000000021", result.getURI());
     240        assertEquals(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"), result.getLastModified());
    241241    }
    242242
     
    254254       
    255255        // to provide integrity, first delete rows in the joint tables
    256         jdbcAnnotationDao.deleteAllAnnotationTarget(5);
    257         jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(5);
    258        
    259         assertEquals(1, jdbcAnnotationDao.deleteAnnotation(5));
    260         assertEquals(0, jdbcAnnotationDao.deleteAnnotation(5));
     256        jdbcAnnotationDao.deleteAllAnnotationTarget(4);
     257        jdbcAnnotationDao.deleteAnnotationPrincipalPermissions(4);
     258       
     259        assertEquals(1, jdbcAnnotationDao.deleteAnnotation(4));
     260        assertEquals(0, jdbcAnnotationDao.deleteAnnotation(4));
    261261    }
    262262
     
    272272        assertEquals(null, annotationToAdd.getLastModified());
    273273       
    274         Number newAnnotationID = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5);
    275         assertEquals(6, newAnnotationID);
     274        Number newAnnotationID = jdbcAnnotationDao.addAnnotation(annotationToAdd, 3);
     275        assertEquals(5, newAnnotationID);
    276276       
    277277        // checking
    278         Annotation addedAnnotation= jdbcAnnotationDao.getAnnotationWithoutTargetsAndPermissions(6);
     278        Annotation addedAnnotation= jdbcAnnotationDao.getAnnotationWithoutTargetsAndPermissions(5);
    279279        assertFalse(null == addedAnnotation.getURI());
    280280        assertFalse(null == addedAnnotation.getLastModified());
     
    294294    public void testRetrieveAnnotationList() {
    295295        System.out.println("test retrieveAnnotationlist");
    296         List<Number> Targets = new ArrayList<Number>();
    297         Targets.add(1);
    298         Targets.add(2);
    299         List<Number> result = jdbcAnnotationDao.retrieveAnnotationList(Targets);
     296        List<Number> targets = new ArrayList<Number>();
     297        targets.add(1);
     298        targets.add(2);
     299        List<Number> result = jdbcAnnotationDao.retrieveAnnotationList(targets);
    300300        assertEquals (2, result.size());
    301         assertEquals(2, result.get(0));
    302         assertEquals(3, result.get(1));
     301        assertEquals(1, result.get(0));
     302        assertEquals(2, result.get(1));
    303303    }
    304304   
     
    310310        System.out.println("getExternalID");
    311311
    312         final UUID externalId = jdbcAnnotationDao.getExternalID(2);
    313         assertEquals(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT), externalId);
     312        final UUID externalId = jdbcAnnotationDao.getExternalID(1);
     313        assertEquals(UUID.fromString("00000000-0000-0000-0000-000000000021"), externalId);
    314314       
    315315        final UUID externalIdThree = jdbcAnnotationDao.getExternalID(null);
     
    332332        //final String link = "nl.wikipedia.org";
    333333        final List<Number> annotationIDs = new ArrayList<Number>();
     334        annotationIDs.add(1);
    334335        annotationIDs.add(2);
    335         annotationIDs.add(3);
    336336       
    337337        List<Number> result_1 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, null, null, null, null, null);       
    338338        assertEquals(2, result_1.size());
    339         assertEquals(2, result_1.get(0));
    340         assertEquals(3, result_1.get(1));
     339        assertEquals(1, result_1.get(0));
     340        assertEquals(2, result_1.get(1));
    341341       
    342342       
    343343        List<Number> result_2 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, null, "some html", null, null, null);       
    344344        assertEquals(2, result_2.size());
    345         assertEquals(2, result_2.get(0));
    346         assertEquals(3, result_2.get(1));
     345        assertEquals(1, result_2.get(0));
     346        assertEquals(2, result_2.get(1));
    347347       
    348348       
     
    351351        final String before = (new Timestamp(System.currentTimeMillis())).toString();
    352352 
    353         List<Number> result_4 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, 4, "some html", null, after, before);       
     353        List<Number> result_4 = jdbcAnnotationDao.getFilteredAnnotationIDs(annotationIDs, 1, "some html", null, after, before);       
    354354        assertEquals(1, result_4.size());
    355         assertEquals(3, result_4.get(0));
     355        assertEquals(1, result_4.get(0));
    356356       
    357357        final String after_1 = (new Timestamp(System.currentTimeMillis())).toString();// no annotations added after "now"       
     
    371371    public void testRetrievePermissions (){
    372372        System.out.println("test Permissions");
    373         List<Map<Number, String>> result = jdbcAnnotationDao.getPermissions(2);
     373        List<Map<Number, String>> result = jdbcAnnotationDao.getPermissions(1);
    374374        assertEquals(2, result.size());
    375         assertEquals("writer", result.get(0).get(4));
    376         assertEquals("reader", result.get(1).get(5));
     375        assertEquals("writer", result.get(0).get(2));
     376        assertEquals("reader", result.get(1).get(3));
    377377       
    378378       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java

    r3830 r4461  
    8686        System.out.println("getExternalId");
    8787        Number internalID = 1;
    88         UUID expResult = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);
     88        UUID expResult = UUID.fromString("00000000-0000-0000-0000-000000000051");
    8989        UUID result = jdbcCachedRepresentationDao.getExternalID(internalID);
    9090        assertEquals(expResult, result);
     
    9898    public void testGetInternalId() {
    9999        System.out.println("test getInternalID");
    100         UUID externalID = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);
     100        UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000051");
    101101        Number result = jdbcCachedRepresentationDao.getInternalID(externalID);
    102102        assertEquals(1, result.intValue());
     
    112112        System.out.println("test getInternalIDFromURI");
    113113        jdbcCachedRepresentationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_cached);
    114         String uri = TestBackendConstants._TEST_SERVLET_URI_cached +TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_;
     114        String uri = TestBackendConstants._TEST_SERVLET_URI_cached +"00000000-0000-0000-0000-000000000051";
    115115        Number result = jdbcCachedRepresentationDao.getInternalIDFromURI(uri);
    116116        assertEquals(1, result.intValue());
     
    128128        jdbcCachedRepresentationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_cached);
    129129        CachedRepresentationInfo result = jdbcCachedRepresentationDao.getCachedRepresentationInfo(1);
    130         assertEquals(TestBackendConstants._TEST_SERVLET_URI_cached + TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getURI());
    131         assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_MIME_TYPE_, result.getMimeType());
    132         assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_TOOL_, result.getTool());
    133         assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_TYPE_, result.getType());
    134         assertEquals(TestBackendConstants._TEST_SERVLET_URI_cached +TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getURI());
     130        assertEquals(TestBackendConstants._TEST_SERVLET_URI_cached + "00000000-0000-0000-0000-000000000051", result.getURI());
     131        assertEquals("text/html", result.getMimeType());
     132        assertEquals("latex", result.getTool());
     133        assertEquals("text", result.getType());
     134        assertEquals(TestBackendConstants._TEST_SERVLET_URI_cached +"00000000-0000-0000-0000-000000000051", result.getURI());
    135135    }
    136136
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDaoTest.java

    r3838 r4461  
    198198//        List<ReTargetREF> testList = jdbcNotebookDao.getAnnotationREFsOfNotebook(3);
    199199//        assertEquals(2, testList.size());       
    200 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT, testList.get(0).getRef());
    201 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_3_EXT, testList.get(1).getRef());
     200//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021", testList.get(0).getRef());
     201//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000022", testList.get(1).getRef());
    202202//       
    203203//        // test Two
     
    205205//        List<ReTargetREF> testListTwo = jdbcNotebookDao.getAnnotationREFsOfNotebook(4);
    206206//        assertEquals(1, testListTwo.size());       
    207 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_4_EXT, testListTwo.get(0).getRef());
     207//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000023", testListTwo.get(0).getRef());
    208208//       
    209209//        // test Three  "empty"
     
    233233//        AnnotationList annotations = jdbcNotebookDao.getAnnotations(3);
    234234//        assertEquals(2, annotations.getAnnotation().size());       
    235 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT, annotations.getAnnotation().get(0).getRef());
    236 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_3_EXT, annotations.getAnnotation().get(1).getRef());
     235//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021", annotations.getAnnotation().get(0).getRef());
     236//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000022", annotations.getAnnotation().get(1).getRef());
    237237//       
    238238//        // test Two
     
    240240//        AnnotationList annotationsTwo = jdbcNotebookDao.getAnnotations(4);
    241241//        assertEquals(1, annotationsTwo.getAnnotation().size());       
    242 //        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_4_EXT, annotationsTwo.getAnnotation().get(0).getRef());
     242//        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000023", annotationsTwo.getAnnotation().get(0).getRef());
    243243//       
    244244//        // test Three  "empty" list of annotations
     
    305305//            {
    306306//              oneOf(annotationDao).getExternalID(2);
    307 //              will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT)));
     307//              will(returnValue(UUID.fromString("00000000-0000-0000-0000-000000000021")));
    308308//             
    309309//              oneOf(annotationDao).getExternalID(3);
    310 //              will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT)));
     310//              will(returnValue(UUID.fromString("00000000-0000-0000-0000-000000000022")));
    311311//            }
    312312//        });
    313313//       
    314314//        List<UUID> resultOne= jdbcNotebookDao.getAnnotationExternalIDs(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_3_EXT));
    315 //        assertEquals(TestBackendConstants._TEST_ANNOT_2_EXT, resultOne.get(0).toString());
    316 //        assertEquals(TestBackendConstants._TEST_ANNOT_3_EXT, resultOne.get(1).toString());
     315//        assertEquals("00000000-0000-0000-0000-000000000021", resultOne.get(0).toString());
     316//        assertEquals("00000000-0000-0000-0000-000000000022", resultOne.get(1).toString());
    317317//       
    318318//       
     
    331331//    private void setMockeryNotebookOne(){       
    332332//        ReTargetREF testRefOne = new ReTargetREF();
    333 //        testRefOne.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_2_EXT);
     333//        testRefOne.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000021");
    334334//        ReTargetREF testRefTwo = new ReTargetREF();
    335 //        testRefTwo.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_3_EXT);
     335//        testRefTwo.setRef(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000022");
    336336//        final List<ReTargetREF> testResult = Arrays.asList(new ReTargetREF[] {testRefOne, testRefTwo});
    337337//       
     
    346346//     private void setMockeryNotebookTwo(){
    347347//        ReTargetREF testRef = new ReTargetREF();
    348 //        testRef.setRef(String.valueOf(TestBackendConstants._TEST_SERVLET_URI_annotations+TestBackendConstants._TEST_ANNOT_4_EXT));
     348//        testRef.setRef(String.valueOf(TestBackendConstants._TEST_SERVLET_URI_annotations+"00000000-0000-0000-0000-000000000023"));
    349349//        final List<ReTargetREF> testResultTwo = Arrays.asList(new ReTargetREF[] {testRef});
    350350//       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDaoTest.java

    r4183 r4461  
    4747   private JdbcTemplate jdbcTemplate;
    4848   
    49    private String getNormalisedSql() throws FileNotFoundException, URISyntaxException {
     49  public static String getNormalisedSql() throws FileNotFoundException, URISyntaxException {
    5050        // remove the unsupported sql for the test
    5151        final URL sqlUrl = JdbcResourceDaoTest.class.getResource("/sql/DashishAnnotatorCreate.sql");
     
    5656            "\\\\connect",
    5757            "SET default_with_oids",
    58             "ALTER SEQUENCE",
    59             "ALTER TABLE ONLY",
    60             "ADD CONSTRAINT",
    61             "CREATE INDEX", // "ALTER TABLE ONLY [a-z]* ALTER COLUMN",
    62         // "ALTER TABLE ONLY [^A]* ADD CONSTRAINT"
     58            //"ALTER SEQUENCE",
     59            //ALTER TABLE ONLY",
     60            //"ADD CONSTRAINT",
     61            //"CREATE INDEX",
     62            // "ALTER TABLE ONLY [a-z]* ALTER COLUMN",
     63            // "ALTER TABLE ONLY [^A]* ADD CONSTRAINT"
    6364        }) {
    6465            sqlString = sqlString.replaceAll(unknownToken, "-- " + unknownToken);
    6566        }
    66         // obsolete(?) Peter's stuff, before body has been decided to be a text with its mimetype: sqlString = sqlString.replaceAll("body_xml xml", "body_xml text");
    67         sqlString = sqlString.replaceAll("CACHE 1;", "; -- CACHE 1;");
     67        //sqlString = sqlString.replaceAll("CACHE 1;", "; -- CACHE 1;");
    6868        //sqlString = sqlString.replaceAll("UUID", "text");
     69        sqlString = sqlString.replaceAll("bytea", "blob");
    6970        sqlString = sqlString.replaceAll("SERIAL NOT NULL", "INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY");
    70         sqlString = sqlString.replaceAll("AT TIME ZONE 'UTC'", "AT TIME ZONE INTERVAL '00:00' HOUR TO MINUTE");
     71        sqlString = sqlString.replaceAll("\\(current_timestamp AT TIME ZONE 'UTC'\\)", "current_timestamp AT TIME ZONE INTERVAL '00:00' HOUR TO MINUTE");
    7172        return sqlString;
    7273    }
    7374
    74     private String getTestDataInsertSql() throws FileNotFoundException, URISyntaxException {
     75    public static String getTestDataInsertSql() throws FileNotFoundException, URISyntaxException {
    7576        final URL sqlUrl = JdbcResourceDaoTest.class.getResource("/test-data/InsertTestData.sql");
    7677        String sqlString = new Scanner(new File(sqlUrl.toURI()), "UTF8").useDelimiter("\\Z").next();
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDaoTest.java

    r4181 r4461  
    8181        Number internalID = 1;
    8282        UUID result = jdbcTargetDao.getExternalID(internalID);
    83         assertEquals(TestBackendConstants._TEST_Target_1_EXT_ID, result.toString());
     83        assertEquals("00000000-0000-0000-0000-000000000031", result.toString());
    8484    }
    8585
     
    9090    public void testGetInternalId() {
    9191        System.out.println("getInternalId");
    92         UUID externalID = UUID.fromString(TestBackendConstants._TEST_Target_1_EXT_ID);
     92        UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000031");
    9393        Number expResult = 1;
    9494        Number result = jdbcTargetDao.getInternalID(externalID);
     
    104104        System.out.println("test getInternalIDFromURI");
    105105        jdbcTargetDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_Targets);
    106         String uri = TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID;
     106        String uri = TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000031";
    107107        Number result = jdbcTargetDao.getInternalIDFromURI(uri);
    108108        assertEquals(1, result.intValue());
     
    118118        jdbcTargetDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_Targets);
    119119        Target result = jdbcTargetDao.getTarget(1);
    120         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID, result.getURI());
    121         assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#"+TestBackendConstants._TEST_Target_1_FRAGMENT, result.getLink());
    122         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, result.getVersion());
     120        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000031", result.getURI());
     121        assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"+"#"+"de_Opdracht", result.getLink());
     122        assertEquals("version 1.0", result.getVersion());
    123123        // TODO :add time stamp test
    124124       
     
    164164
    165165        Target freshTarget = new Target();
    166         freshTarget.setLink(TestBackendConstants._TEST_Target_1_LINK+"#Het_ontwerp");
    167         freshTarget.setVersion(TestBackendConstants._TEST_Target_1_VERSION);
     166        freshTarget.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"+"#Het_ontwerp");
     167        freshTarget.setVersion("version 1.0");
    168168        freshTarget.setLastModified(null);
    169169       
     
    172172        // detailed checking
    173173        Target addedTarget = jdbcTargetDao.getTarget(result);
    174         assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#Het_ontwerp", addedTarget.getLink());
    175         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, addedTarget.getVersion());
     174        assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"+"#Het_ontwerp", addedTarget.getLink());
     175        assertEquals("version 1.0", addedTarget.getVersion());
    176176        assertTrue(addedTarget.getURI().startsWith(TestBackendConstants._TEST_SERVLET_URI_Targets));
    177177    }
     
    189189        List<TargetInfo> result = jdbcTargetDao.getTargetInfos(test);
    190190        assertEquals(2, result.size());
    191         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID, result.get(0).getRef());
    192         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_2_EXT_ID, result.get(1).getRef());
    193         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, result.get(0).getVersion());
    194         assertEquals(TestBackendConstants._TEST_Target_2_VERSION, result.get(1).getVersion());
    195         assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#"+TestBackendConstants._TEST_Target_1_FRAGMENT, result.get(0).getLink());
    196         assertEquals(TestBackendConstants._TEST_Target_2_LINK+"#Vroege_werk", result.get(1).getLink());
     191        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000031", result.get(0).getRef());
     192        assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+"00000000-0000-0000-0000-000000000032", result.get(1).getRef());
     193        assertEquals("version 1.0", result.get(0).getVersion());
     194        assertEquals("version 1.1", result.get(1).getVersion());
     195        assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"+"#"+"de_Opdracht", result.get(0).getLink());
     196        assertEquals("http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD"+"#Vroege_werk", result.get(1).getLink());
    197197
    198198    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDaoTest.java

    r4281 r4461  
    7575    @Test
    7676    public void testGetInternalID() {
    77         Number testOne = jdbcUserDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_USER_3_EXT_ID));
     77        Number testOne = jdbcUserDao.getInternalID(UUID.fromString("00000000-0000-0000-0000-000000000113"));
    7878        assertEquals(3, testOne.intValue());
    7979
    80         Number testTwo = jdbcUserDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_USER_XXX_EXT_ID));
     80        Number testTwo = jdbcUserDao.getInternalID(UUID.fromString("00000000-0000-0000-0000-000000000ccc"));
    8181        assertEquals(null, testTwo);
    8282
     
    8989    public void testGetExternalID() {
    9090        UUID testOne = jdbcUserDao.getExternalID(3);
    91         assertEquals(TestBackendConstants._TEST_USER_3_EXT_ID, testOne.toString());
     91        assertEquals("00000000-0000-0000-0000-000000000113", testOne.toString());
    9292
    9393        UUID testTwo = jdbcUserDao.getExternalID(null);
     
    9999        System.out.println("test getUser");
    100100        jdbcUserDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_users);
    101         Number internalID = 1;
    102         User result = jdbcUserDao.getUser(internalID);
    103         assertEquals("a user", result.getDisplayName());
    104         assertEquals("a.user@gmail.com", result.getEMail());
    105         assertEquals(TestBackendConstants._TEST_SERVLET_URI_users+TestBackendConstants._TEST_UID_1_, result.getURI());
     101        User result = jdbcUserDao.getUser(1);
     102        assertEquals("Twan", result.getDisplayName());
     103        assertEquals("Twan.Goosen@mpi.nl", result.getEMail());
     104        assertEquals(TestBackendConstants._TEST_SERVLET_URI_users+"00000000-0000-0000-0000-000000000111", result.getURI());
    106105    }
    107106
     
    118117
    119118        Number result = jdbcUserDao.addUser(freshUser, "secret X");
    120         assertEquals(7, result.intValue());
     119        assertEquals(11, result.intValue());
    121120        User addedUser = jdbcUserDao.getUser(result);
    122121        assertEquals(freshUserName, addedUser.getDisplayName());
     
    130129        jdbcUserDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI_users);
    131130
    132         int result = jdbcUserDao.deleteUser(6);
     131        int result = jdbcUserDao.deleteUser(10);
    133132        assertEquals(1, result);
    134         User check = jdbcUserDao.getUser(6);
     133        User check = jdbcUserDao.getUser(10);
    135134        assertTrue(null==check);
    136135    }
     
    139138    @Test
    140139    public void testUserIsInUse(){
    141         assertTrue(jdbcUserDao.userIsInUse(2));
    142         assertTrue(jdbcUserDao.userIsInUse(5));
    143         assertFalse(jdbcUserDao.userIsInUse(6));
     140        assertTrue(jdbcUserDao.userIsInUse(1));
     141        assertTrue(jdbcUserDao.userIsInUse(3));
     142        assertFalse(jdbcUserDao.userIsInUse(10));
    144143    }
    145144
     
    156155        User user = new User();
    157156        user.setDisplayName("Olha");
    158         user.setEMail("olhsha@mpi.nl");
     157        user.setEMail("Olha.Shakaravska@mpi.nl");
    159158        assertTrue(jdbcUserDao.userExists(user));
    160159
  • 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               
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r4429 r4461  
    9292    }
    9393   
    94     private String getNormalisedSql() throws FileNotFoundException, URISyntaxException {
    95         // remove the unsupported sql for the test
    96         final URL sqlUrl = JdbcResourceDaoTest.class.getResource("/sql/DashishAnnotatorCreate.sql");
    97         String sqlString = new Scanner(new File(sqlUrl.toURI()), "UTF8").useDelimiter("\\Z").next();
    98         for (String unknownToken : new String[]{
    99                     "SET client_encoding",
    100                     "CREATE DATABASE",
    101                     "\\\\connect",
    102                     "SET default_with_oids",
    103                     "ALTER SEQUENCE",
    104                     "ALTER TABLE ONLY",
    105                     "ADD CONSTRAINT",
    106                     "CREATE INDEX", // "ALTER TABLE ONLY [a-z]* ALTER COLUMN",
    107                 // "ALTER TABLE ONLY [^A]* ADD CONSTRAINT"
    108                 }) {
    109             sqlString = sqlString.replaceAll(unknownToken, "-- " + unknownToken);
    110         }
    111         // obsolete(?) Peter's stuff, before body has been decided to be a text with its mimetype: sqlString = sqlString.replaceAll("body_xml xml", "body_xml text");
    112         sqlString = sqlString.replaceAll("CACHE 1;", "; -- CACHE 1;");
    113         //sqlString = sqlString.replaceAll("UUID", "text");
    114         sqlString = sqlString.replaceAll("SERIAL NOT NULL", "INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY");       
    115         sqlString = sqlString.replaceAll("AT TIME ZONE 'UTC'", "AT TIME ZONE INTERVAL '00:00' HOUR TO MINUTE");
    116         return sqlString;
    117     }
    118    
    119     private String getTestDataInsertSql() throws FileNotFoundException, URISyntaxException {
    120         final URL sqlUrl = AnnotationsTest.class.getResource("/test-data/InsertTestData.sql");
    121         String sqlString = new Scanner(new File(sqlUrl.toURI()), "UTF8").useDelimiter("\\Z").next();
    122         return sqlString;
    123     }
    124    
    12594   
    12695   
     
    131100        jdbcTemplate.execute("DROP SCHEMA PUBLIC CASCADE");
    132101        // consume the DashishAnnotatorCreate sql script to create the database
    133         jdbcTemplate.execute(getNormalisedSql());
    134         jdbcTemplate.execute(getTestDataInsertSql());
     102        jdbcTemplate.execute(JdbcResourceDaoTest.getNormalisedSql());
     103        jdbcTemplate.execute(JdbcResourceDaoTest.getTestDataInsertSql());
    135104    }
    136105
     
    147116    public void testGetAnnotation() throws SQLException, DatatypeConfigurationException {
    148117        System.out.println("testGetAnnotation");
    149         final String externalIDstring = TestBackendConstants._TEST_ANNOT_2_EXT;
     118        final String externalIDstring = "00000000-0000-0000-0000-000000000021";
    150119        final Annotation testAnnotation = (new TestInstances(resource().getURI().toString())).getAnnotationOne();       
    151120       
     
    163132        assertEquals(2, entity.getPermissions().getUserWithPermission().size());
    164133        assertEquals("writer", entity.getPermissions().getUserWithPermission().get(0).getPermission().value());
    165         assertEquals(resource().getURI()+"users/"+TestBackendConstants._TEST_USER_4_EXT_ID, entity.getPermissions().getUserWithPermission().get(0).getRef());
     134        assertEquals(resource().getURI()+"users/"+"00000000-0000-0000-0000-000000000112", entity.getPermissions().getUserWithPermission().get(0).getRef());
    166135        assertEquals("reader", entity.getPermissions().getUserWithPermission().get(1).getPermission().value());
    167         assertEquals(resource().getURI()+"users/"+TestBackendConstants._TEST_USER_5_EXT_ID, entity.getPermissions().getUserWithPermission().get(1).getRef());
     136        assertEquals(resource().getURI()+"users/"+"00000000-0000-0000-0000-000000000113", entity.getPermissions().getUserWithPermission().get(1).getRef());
    168137        assertEquals(2, entity.getTargets().getTargetInfo().size());
    169         assertEquals(resource().getURI().toString()+"targets/"+TestBackendConstants._TEST_Target_1_EXT_ID, entity.getTargets().getTargetInfo().get(0).getRef());
    170         assertEquals(resource().getURI().toString()+"targets/"+TestBackendConstants._TEST_Target_2_EXT_ID, entity.getTargets().getTargetInfo().get(1).getRef());
     138        assertEquals(resource().getURI().toString()+"targets/"+"00000000-0000-0000-0000-000000000031", entity.getTargets().getTargetInfo().get(0).getRef());
     139        assertEquals(resource().getURI().toString()+"targets/"+"00000000-0000-0000-0000-000000000032", entity.getTargets().getTargetInfo().get(1).getRef());
    171140        assertEquals(testAnnotation.getLastModified(), entity.getLastModified());
    172141        assertEquals(resource().getURI()+requestUrl, entity.getURI());
     
    180149    public void testDeleteAnnotation() throws SQLException {
    181150        System.out.println("testDeleteAnnotation");
    182         String externalIDstring  =  TestBackendConstants._TEST_ANNOT_5_EXT;
     151        String externalIDstring  =  "00000000-0000-0000-0000-000000000024";
    183152        final String requestUrl = "annotations/" + externalIDstring;
    184153        System.out.println("requestUrl: " + requestUrl);
     
    198167        System.out.println("test createAnnotation");
    199168        System.out.println("POST "+resource().getURI().toString()+"annotations/");
    200         final String ownerString = resource().getURI().toString()+"users/"+TestBackendConstants._TEST_USER_5_EXT_ID;
     169        final String ownerString = resource().getURI().toString()+"users/"+"00000000-0000-0000-0000-000000000113";
    201170        final Annotation annotationToAdd = new Annotation();
    202171        final JAXBElement<Annotation> jaxbElement = (new ObjectFactory()).createAnnotation(annotationToAdd);
     
    204173        annotationToAdd.setOwnerRef(ownerString);
    205174        annotationToAdd.setURI(resource().getURI().toString()+"annotations/"+ UUID.randomUUID().toString());       
    206         annotationToAdd.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP));       
     175        annotationToAdd.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"));       
    207176       
    208177        TargetInfoList targetInfoList = new TargetInfoList();
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/DummyPrincipal.java

    r4173 r4461  
    2929
    3030    public static final DummyPrincipal DUMMY_ADMIN_PRINCIPAL = new DummyPrincipal("JUnit.Admin@test.com");
    31     public static final DummyPrincipal DUMMY_PRINCIPAL = new DummyPrincipal("JUnit@test.com");
     31    public static final DummyPrincipal DUMMY_PRINCIPAL = new DummyPrincipal("olhsha@mpi.nl");
    3232    public static final UserCredentials DUMMY_CREDENTIALS = new UserCredentials(DUMMY_PRINCIPAL) {
    3333
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java

    r4000 r4461  
    160160//        System.out.println("test getAllAnnotations");       
    161161//        final String externalID= TestBackendConstants._TEST_NOTEBOOK_3_EXT;
    162 //        final UUID aIdOne= UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT);
    163 //        final UUID aIdTwo= UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT);
     162//        final UUID aIdOne= UUID.fromString("00000000-0000-0000-0000-000000000021");
     163//        final UUID aIdTwo= UUID.fromString("00000000-0000-0000-0000-000000000022");
    164164//        final List<UUID> annotationIds = new ArrayList<UUID>();
    165165//        annotationIds.add(aIdOne);
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql

    r4429 r4461  
    2121--
    2222
    23 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('a user', '00000000-0000-0000-0000-000000000003', 'a1', 'a.user@gmail.com', 'user'); -- 1
    24 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('b user', '00000000-0000-0000-0000-000000000004', 'b2', 'b.user@gmail.com', 'user');-- 2
    25 
    26 INSERT INTO notebook (title, owner_id, external_id) VALUES ('a notebook', 2, '00000000-0000-0000-0000-000000000001'); -- 1
    27 -- INSERT INTO notebook (title, owner_id, external_id) VALUES ('a notebook', 1, 1);
    28 
    29 INSERT INTO annotation (owner_id, headline, body_text, body_mimetype, external_id, is_xml) VALUES (1, 'a headline', '<html><body>some html</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000005', false); --1
    30 
    31 INSERT INTO notebook (title, owner_id, external_id) VALUES ('a second notebook', 2, '00000000-0000-0000-0000-000000000002'); --2
    32 -- INSERT INTO notebook (title, owner_id, external_id) VALUES ('a second notebook', 1, 2);
    33 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (1,1);
    34 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (2,1);
     23INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Twan', '00000000-0000-0000-0000-000000000111', 'twagoo@mpi.nl', 'Twan.Goosen@mpi.nl', 'developer'); --1
     24INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Peter', '00000000-0000-0000-0000-000000000112', 'petwit@mpi.nl', 'Peter.Withers@mpi.nl', 'developer'); -- 2
     25INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Olha', '00000000-0000-0000-0000-000000000113', 'olhsha@mpi.nl', 'Olha.Shakaravska@mpi.nl', 'admin'); -- 3
     26INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Eric', '00000000-0000-0000-0000-000000000114', 'ericauser@mpi.nl', 'Eric.Auer@mpi.nl', 'developer'); -- 4
     27INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Daan', '00000000-0000-0000-0000-000000000115', 'broeder@mpi.ml', 'Daan.Broeder@mpi.nl', 'developer'); --5
     28INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Menzo', '00000000-0000-0000-0000-000000000116', 'menwin@mpi.nl', 'Menzo.Windhouwer@mpi.nl', 'developer'); -- 6
     29INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Przemek', '00000000-0000-0000-0000-000000000117', 'przlen@mpi,nl', 'Przemek.Lenkiewicz@mpi.nl', 'user'); -- 7
     30INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Stephanie', '00000000-0000-0000-0000-000000000118', 'gusrotst@gu.se', 'stephanie.roth@gu.se', 'developer'); -- 8
     31INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Olof', '00000000-0000-0000-0000-000000000119', 'gusolsol@gu.se', 'olof.olsson.2@gu.se', 'developer'); -- 9
     32INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Willem', '00000000-0000-0000-0000-000000000220', 'wilelb@mpi.nl', 'Willem.Elbers@mpi.nl', 'developer'); -- 10
    3533
    3634
    37 -- Test data for jdbcAnnotationDao --
     35INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 3', 1, '00000000-0000-0000-0000-000000000011'); -- 1
     36INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 4', 2, '00000000-0000-0000-0000-000000000012'); --2
     37INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 5', 3, '00000000-0000-0000-0000-000000000013'); --3
     38INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 6', 3, '00000000-0000-0000-0000-000000000014'); --4
    3839
    39 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Twan', '00000000-0000-0000-0000-000000000111', 'x3', 'twagoo@mpi.nl', 'developer'); --3
    40 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Peter', '00000000-0000-0000-0000-000000000112', 'y4', 'Peter.Withers@mpi.nl', 'developer'); -- 4
    41 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Olha', '00000000-0000-0000-0000-000000000113', 'JUnit@test.com', 'olhsha@mpi.nl', 'admin'); -- 5
    42 INSERT INTO principal (principal_name, external_id, remote_id, e_mail, account) VALUES ('Eric', '00000000-0000-0000-0000-000000000114', 'v6', 'eriaue@mpi.nl', 'developer'); -- 6
    43 
    44 
    45 INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 3', 3, '00000000-0000-0000-0000-000000000011'); -- 3
    46 INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 4', 4, '00000000-0000-0000-0000-000000000012'); --4
    47 INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 5', 5, '00000000-0000-0000-0000-000000000013'); --5
    48 INSERT INTO notebook (title, owner_id, external_id) VALUES ('Notebook 6', 5, '00000000-0000-0000-0000-000000000014'); --6
    49 
    50 INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, last_modified, is_xml) VALUES (3, 'Sagrada Famiglia','<html><body>some html 1</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000021', '2013-08-12 09:25:00.383', false); --2
    51 INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (4, 'Gaudi','<html><body>some html 2</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000022',false); --3
    52 INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (5, 'Art Nuveau','some plain text', 'text/plain' , '00000000-0000-0000-0000-000000000023', false); --4
    53 INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (5, 'Annotation to delete','<html><body>some html 4</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000024',false); --5
     40INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, last_modified, is_xml) VALUES (1, 'Sagrada Famiglia','<html><body>some html 1</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000021', '2013-08-12 09:25:00.383', false); --1
     41INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (2, 'Gaudi','<html><body>some html 2</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000022',false); --2
     42INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (3, 'Art Nuveau','some plain text', 'text/plain' , '00000000-0000-0000-0000-000000000023', false); --3
     43INSERT INTO annotation (owner_id, headline,body_text, body_mimetype, external_id, is_xml) VALUES (3, 'Annotation to delete','<html><body>some html 4</body></html>', 'text/html' , '00000000-0000-0000-0000-000000000024',false); --4
    5444
    5545
    5646
    57 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (3,2);
    58 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (3,3);
    59 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (4,4);
    60 INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (5,4);
     47INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (1,1);
     48INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (1,2);
     49INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (2,3);
     50INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (4,3);
    6151
    6252
    6353INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000031', 'http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia', 'version 1.0', 'de_Opdracht'); -- 1
    64 INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000032', 'http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD', 'version 1.0', 'Vroege_werk'); --2
     54INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000032', 'http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD', 'version 1.1', 'Vroege_werk'); --2
    6555INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000033', 'http://en.wikipedia.org/wiki/Art_Nouveau', 'june 1013', 'Spain'); --3
    6656INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000034', '???', 'back up', '1111'); --4
    6757INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000035', '???', 'back up', '111111'); --5
    6858INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000036', '???', 'version 2.0', '1111111'); --6 not used by any annotation
    69 INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000037', '???', 'version 2.0', '11111111');
     59INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000037', '???', 'version 2.0', '11111111'); --7
    7060
    7161
    7262
    73 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (2, 1);
    74 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (2, 2);
    75 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (3, 2);
    76 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (4, 3);
    77 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (5, 3); -- Target 3 should not be deleted when annot 5 is deleted
    78 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (5, 4); -- Target 4 to be deleted when annot 5 is deleted
    79 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (4, 5);
    80 INSERT INTO annotations_targets (annotation_id, target_id) VALUES (4, 7);
     63INSERT INTO annotations_targets (annotation_id, target_id) VALUES (1, 1);
     64INSERT INTO annotations_targets (annotation_id, target_id) VALUES (1, 2);
     65INSERT INTO annotations_targets (annotation_id, target_id) VALUES (2, 2);
     66INSERT INTO annotations_targets (annotation_id, target_id) VALUES (3, 3);
     67INSERT INTO annotations_targets (annotation_id, target_id) VALUES (4, 3); -- Target 3 should not be deleted when annot 4 is deleted
     68INSERT INTO annotations_targets (annotation_id, target_id) VALUES (4, 4); -- Target 4 to be deleted when annot 4 is deleted
     69INSERT INTO annotations_targets (annotation_id, target_id) VALUES (3, 5);
     70INSERT INTO annotations_targets (annotation_id, target_id) VALUES (3, 7);
    8171
    8272INSERT INTO cached_representation (external_id, mime_type, tool, type_, file_) VALUES ('00000000-0000-0000-0000-000000000051', 'text/html', 'latex', 'text', X'1001'); --1
     
    9989
    10090
    101 
    102 
    103 
    10491---- PERMISSIONS --------------------------------------------------------------------------------------------
    10592
     
    10895INSERT INTO permission_(permission_mode) VALUES ('reader');
    10996
    110 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 4, 'writer');
    111 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 5, 'reader');
     97INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (1, 2, 'writer');
     98INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (1, 3, 'reader');
    11299
    113 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 3, 'reader');
    114 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 5, 'writer');
     100INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 1, 'reader');
     101INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 3, 'writer');
    115102
    116 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 3, 'reader');
    117 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 4, 'reader');
     103INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 1, 'reader');
     104INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 2, 'reader');
    118105
    119 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 4, 'writer');
    120 INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 3, 'writer');
     106INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 2, 'writer');
     107INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 1, 'writer');
    121108-- checking integrity control:
    122109-- INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 5, 'reader');
Note: See TracChangeset for help on using the changeset viewer.