LayoutItemPortalDeepCloneTest: Test something to avoid warnings.
[online-glom:gwt-glom.git] / src / test / java / org / glom / web / server / libglom / LayoutItemPortalDeepCloneTest.java
1 /*
2  * Copyright (C) 2012 Openismus GmbH
3  *
4  * This file is part of GWT-Glom.
5  *
6  * GWT-Glom is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with GWT-Glom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 package org.glom.web.server.libglom;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertTrue;
24
25 import org.glom.web.server.Utils;
26 import org.glom.web.shared.libglom.Relationship;
27 import org.glom.web.shared.libglom.layout.LayoutItemField;
28 import org.glom.web.shared.libglom.layout.LayoutItemPortal;
29 import org.junit.Test;
30
31 /**
32  * @author Murray Cumming <murrayc@openismus.com>
33  * 
34  */
35 public class LayoutItemPortalDeepCloneTest {
36
37         @Test
38         public void test() {
39                 final String testTableFrom = "testTableFrom";
40                 final String testFieldFrom = "testFieldFrom";
41                 final String testTableTo = "testTableTo";
42                 final String testFieldTo = "testFieldTo";
43
44                 final Relationship relationship = new Relationship();
45                 relationship.setFromTable(testTableFrom);
46                 relationship.setFromField(testFieldFrom);
47                 relationship.setToTable(testTableTo);
48                 relationship.setToField(testFieldTo);
49
50                 final LayoutItemPortal portal = new LayoutItemPortal();
51                 portal.setRelationship(relationship);
52
53                 LayoutItemField item = new LayoutItemField();
54                 item.setName("testfield1");
55                 portal.addItem(item);
56                 item = new LayoutItemField();
57                 item.setName("testfield2");
58                 portal.addItem(item);
59
60                 final LayoutItemPortal clonePortal = (LayoutItemPortal) Utils.deepCopy(portal);
61                 assertTrue(clonePortal != null);
62                 final Relationship cloneRelationship = clonePortal.getRelationship();
63                 assertTrue(cloneRelationship != null);
64                 assertEquals(cloneRelationship.getFromTable(), testTableFrom);
65                 assertEquals(cloneRelationship.getFromField(), testFieldFrom);
66                 assertEquals(cloneRelationship.getToTable(), testTableTo);
67                 assertEquals(cloneRelationship.getToField(), testFieldTo);
68         }
69 }