Salome HOME
48d825ee8fc80bbdc062f30e3d938ecfa719f94f
[modules/gde.git] / projects / GDE_App / GDE-war / test / com / edf / gde / test / dao / AttributeDaoTest.java
1 /*
2  * (C) 2015 EDF
3  */
4 package com.edf.gde.test.dao;
5
6 import com.edf.gde.dao.AttributeDaoClient;
7 import com.edf.gde.test.base.BaseTest;
8 import com.edf.gde.transferables.AttributeGroupTO;
9 import com.edf.gde.transferables.AttributeTO;
10 import org.junit.After;
11 import org.junit.AfterClass;
12 import org.junit.Assert;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertTrue;
16 import org.junit.Before;
17 import org.junit.BeforeClass;
18 import org.junit.Test;
19
20 /**
21  *
22  * @author mordicus
23  */
24 public class AttributeDaoTest extends BaseTest {
25
26     @BeforeClass
27     public static void setUpClass() {
28     }
29
30     @AfterClass
31     public static void tearDownClass() {
32     }
33
34     @Before
35     public void setUp() {
36     }
37
38     @After
39     public void tearDown() {
40     }
41
42     @Test
43     public void testCreateAttribute() throws Exception {
44         AttributeDaoClient daoClient = new AttributeDaoClient();
45         testName("createAttribute");
46         
47         /* Create an instance of AttributeGroup*/
48         AttributeGroupTO attributeGroup = new AttributeGroupTO();
49         AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
50         assertNotNull(resultAttributeGroup);
51         assertTrue(resultAttributeGroup.getId()>0);
52         AttributeTO ato = new AttributeTO();
53         ato.setName("Attribute1");
54         ato.setType("integer");
55         ato.setValue("12");
56         ato.setGroupId(resultAttributeGroup.getId());
57         AttributeTO newAttribute = daoClient.createAttribute(ato);
58         
59         assertNotNull(newAttribute);
60         assertEquals(ato.getName(),newAttribute.getName());
61         assertTrue(newAttribute.getId()!=0);
62         try {
63         daoClient.deleteAttribute(newAttribute.getId());
64         } catch (Exception e) {
65             Assert.fail("Error deleting attribute");
66         }
67         try {
68         System.out.println("Deleting group " + resultAttributeGroup.getId());
69         daoClient.deleteAttributeGroup(resultAttributeGroup.getId());
70         } catch (Exception e) {
71             Assert.fail("Error deleting attribute group");
72         }
73         passed();
74     }
75 }