source: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java @ 4173

Last change on this file since 4173 was 4173, checked in by olhsha, 10 years ago

lintegrity unit test reconstructed so it does not mock any more. getAnnotation works (the others are "ignored"). Needs refactoring (the subdirectory with beans and DummySecurityFilter? class.

File size: 3.7 KB
Line 
1/**
2 * Copyright (C) 2013 DASISH
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18package eu.dasish.annotation.backend;
19
20import eu.dasish.annotation.schema.Annotation;
21import eu.dasish.annotation.schema.AnnotationBody;
22import eu.dasish.annotation.schema.AnnotationBody.TextBody;
23import eu.dasish.annotation.schema.TargetInfo;
24import eu.dasish.annotation.schema.TargetInfoList;
25import javax.xml.datatype.DatatypeConfigurationException;
26import javax.xml.datatype.DatatypeFactory;
27
28/**
29 *
30 * @author olhsha
31 */
32public class TestInstances {
33   
34    final private Annotation _annotationOne;
35    final private Annotation _annotationToAdd;
36   
37    public TestInstances(String baseURI){
38        _annotationOne = makeAnnotationOne(baseURI);
39        _annotationToAdd = makeAnnotationToAdd(baseURI);   
40    }
41   
42   
43    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);
45        try {
46        result.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(TestBackendConstants._TEST_ANNOT_2_TIME_STAMP));
47        } catch (DatatypeConfigurationException dce) {
48            System.out.println("wrongly-formatted test timestamp "+TestBackendConstants._TEST_ANNOT_2_TIME_STAMP);
49            result.setLastModified(null);
50        }
51        return result;
52    }
53   
54    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);
56       
57       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); 
61       
62       TargetInfoList targetInfos =  new TargetInfoList();
63       targetInfos.getTargetInfo().add(TargetInfo);
64       result.setTargets(targetInfos);
65       
66       return result;
67    }
68   
69
70    private Annotation makeAnnotation(String baseURI, String bodyTxt, String bodyMimeType, String headline, String ownerID){
71        Annotation result = new Annotation();
72        AnnotationBody body = new AnnotationBody();
73        result.setBody(body);
74        TextBody textBody = new TextBody();
75        body.setTextBody(textBody);
76        textBody.setMimeType(bodyMimeType);
77        textBody.setValue(bodyTxt);
78       
79        result.setHeadline(headline);
80        result.setOwnerRef(baseURI+"users/"+ownerID); 
81       
82        result.setLastModified(null); 
83        result.setURI(null);
84        result.setTargets(null);
85        result.setURI(null);
86       
87       return result;
88    }
89   
90   
91    public Annotation getAnnotationOne(){
92        return _annotationOne;
93    }
94   
95    public Annotation getAnnotationToAdd(){
96        return _annotationToAdd;
97    }
98   
99   
100}
Note: See TracBrowser for help on using the repository browser.