4 package com.edf.gde.test.dao;
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;
24 public class AttributeDaoTest extends BaseTest {
27 public static void setUpClass() {
31 public static void tearDownClass() {
39 public void tearDown() {
43 public void testCreateAttribute() throws Exception {
44 AttributeDaoClient daoClient = new AttributeDaoClient();
45 testName("createAttribute");
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");
56 ato.setGroupId(resultAttributeGroup.getId());
57 AttributeTO newAttribute = daoClient.createAttribute(ato);
59 assertNotNull(newAttribute);
60 assertEquals(ato.getName(),newAttribute.getName());
61 assertTrue(newAttribute.getId()!=0);
63 daoClient.deleteAttribute(newAttribute.getId());
64 } catch (Exception e) {
65 Assert.fail("Error deleting attribute");
68 System.out.println("Deleting group " + resultAttributeGroup.getId());
69 daoClient.deleteAttributeGroup(resultAttributeGroup.getId());
70 } catch (Exception e) {
71 Assert.fail("Error deleting attribute group");