Salome HOME
Attribute DAO
[modules/gde.git] / projects / GDE_App / GDE-war / test / com / edf / gde / test / dao / AttributeDaoTest.java
index 91fde671ea2b8411137f6e32f45b1014b43517d5..48d825ee8fc80bbdc062f30e3d938ecfa719f94f 100644 (file)
@@ -5,8 +5,14 @@ package com.edf.gde.test.dao;
 
 import com.edf.gde.dao.AttributeDaoClient;
 import com.edf.gde.test.base.BaseTest;
+import com.edf.gde.transferables.AttributeGroupTO;
+import com.edf.gde.transferables.AttributeTO;
 import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -35,7 +41,35 @@ public class AttributeDaoTest extends BaseTest {
 
     @Test
     public void testCreateAttribute() throws Exception {
-        testName("createAttribute");
         AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("createAttribute");
+        
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId()>0);
+        AttributeTO ato = new AttributeTO();
+        ato.setName("Attribute1");
+        ato.setType("integer");
+        ato.setValue("12");
+        ato.setGroupId(resultAttributeGroup.getId());
+        AttributeTO newAttribute = daoClient.createAttribute(ato);
+        
+        assertNotNull(newAttribute);
+        assertEquals(ato.getName(),newAttribute.getName());
+        assertTrue(newAttribute.getId()!=0);
+        try {
+        daoClient.deleteAttribute(newAttribute.getId());
+        } catch (Exception e) {
+            Assert.fail("Error deleting attribute");
+        }
+        try {
+        System.out.println("Deleting group " + resultAttributeGroup.getId());
+        daoClient.deleteAttributeGroup(resultAttributeGroup.getId());
+        } catch (Exception e) {
+            Assert.fail("Error deleting attribute group");
+        }
+        passed();
     }
 }