test classes and datasets for status editor
[cdm-vaadin.git] / src / test / java / eu / etaxonomy / cdm / vaadin / presenter / StatusPresenterTest.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.vaadin.presenter;
11
12 import java.sql.SQLException;
13 import java.util.Collection;
14
15 import org.apache.log4j.Logger;
16 import org.junit.Assert;
17 import org.junit.BeforeClass;
18 import org.junit.Test;
19 import org.unitils.dbunit.annotation.DataSet;
20
21 import com.vaadin.data.Item;
22
23 import eu.etaxonomy.cdm.vaadin.CdmVaadinBaseTest;
24 import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
25 import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer;
26
27 /**
28 * @author cmathew
29 * @date 10 Mar 2015
30 *
31 */
32 @DataSet
33 public class StatusPresenterTest extends CdmVaadinBaseTest {
34
35 private static final Logger logger = Logger.getLogger(StatusPresenterTest.class);
36
37 private static StatusPresenter sp;
38
39 @BeforeClass
40 public static void init() {
41 sp = new StatusPresenter(null);
42 }
43
44 @Test
45 public void testLoadTaxa() throws SQLException {
46 LeafNodeTaxonContainer container = sp.loadTaxa(11);
47 Collection<?> propIds = container.getContainerPropertyIds();
48 Collection<?> itemIds = container.getItemIds();
49 for(Object itemId : itemIds) {
50 Item item = container.getItem(itemId);
51 // column names need to be uppercase for h2 in the test environment
52 //String taxon = (String)item.getItemProperty("TAXON").getValue();
53 //logger.info("taxon : " + taxon);
54 }
55 Assert.assertEquals(3,itemIds.size());
56 }
57
58 @Test
59 public void testLoadClassifications() throws SQLException {
60 CdmSQLContainer container = sp.loadClassifications();
61 Collection<?> itemIds = container.getItemIds();
62 String[] uuids = {"6595638e-4993-421a-9fe5-76b09d94f36a", "1ef8aada-de72-4023-bbe1-14465b6bc60d"};
63 int count = 0;
64 for(Object itemId : itemIds) {
65 Item item = container.getItem(itemId);
66
67 String uuid = (String)item.getItemProperty("UUID").getValue();
68 Assert.assertEquals(uuids[count], uuid);
69 String titleCache = (String)item.getItemProperty("TITLECACHE").getValue();
70 logger.info("titleCache : " + titleCache);
71 count++;
72
73 }
74 }
75 }