1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.store.legacy.doc.internal

File ListAttachmentArchiveTest.java

 

Code metrics

0
20
1
1
70
36
1
0.05
20
1
1

Classes

Class Line # Actions
ListAttachmentArchiveTest 39 20 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.store.legacy.doc.internal;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.junit.jupiter.api.Test;
26    import org.suigeneris.jrcs.rcs.Version;
27    import org.xwiki.model.reference.DocumentReference;
28   
29    import com.xpn.xwiki.doc.XWikiAttachment;
30    import com.xpn.xwiki.doc.XWikiDocument;
31   
32    import static org.junit.jupiter.api.Assertions.assertEquals;
33   
34    /**
35    * Validate {@link ListAttachmentArchive}.
36    *
37    * @version $Id: 9f6969b47df528e2f86550aa17af5bf99f839f0e $
38    */
 
39    public class ListAttachmentArchiveTest
40    {
 
41  1 toggle @Test
42    public void testSort()
43    {
44  1 XWikiDocument document = new XWikiDocument(new DocumentReference("wiki", "space", "page"));
45   
46  1 XWikiAttachment attachment11 = new XWikiAttachment(document, "file1");
47  1 attachment11.setVersion("1.1");
48  1 XWikiAttachment attachment12 = new XWikiAttachment(document, "file1");
49  1 attachment12.setVersion("1.2");
50  1 XWikiAttachment attachment31 = new XWikiAttachment(document, "file1");
51  1 attachment31.setVersion("3.1");
52  1 XWikiAttachment attachment41 = new XWikiAttachment(document, "file1");
53  1 attachment41.setVersion("4.1");
54   
55  1 List<XWikiAttachment> attachments = new ArrayList<>();
56  1 attachments.add(attachment41);
57  1 attachments.add(attachment11);
58  1 attachments.add(attachment12);
59  1 attachments.add(attachment31);
60   
61  1 ListAttachmentArchive archive = new ListAttachmentArchive(attachments);
62   
63  1 Version[] versions = archive.getVersions();
64   
65  1 assertEquals("1.1", versions[0].toString());
66  1 assertEquals("1.2", versions[1].toString());
67  1 assertEquals("3.1", versions[2].toString());
68  1 assertEquals("4.1", versions[3].toString());
69    }
70    }