From d87a8d6a847c5655c9bceece97e1c1474d6d2b4a Mon Sep 17 00:00:00 2001 From: Bojnourdi Date: Thu, 13 Aug 2015 18:07:12 +0200 Subject: [PATCH] Attribute DAO More tests --- .../test/com/edf/gde/test/base/BaseTest.java | 2 +- .../edf/gde/test/dao/AttributeDaoTest.java | 61 ++++++++++++++----- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java index ce6e57d..763d801 100644 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java @@ -17,6 +17,6 @@ public class BaseTest { } protected void passed() { - System.out.println("\t\t[PASSED]"); + System.out.println(" -- [OK]"); } } diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java index 1469819..30f44a1 100644 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java @@ -9,7 +9,6 @@ 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; @@ -43,32 +42,64 @@ public class AttributeDaoTest extends BaseTest { public void testCreateAttribute() throws Exception { 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); + assertTrue(resultAttributeGroup.getId() > 0); + /* Create Attribute */ 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 { + assertEquals(ato.getName(), newAttribute.getName()); + assertTrue(newAttribute.getId() != 0); + passed(); + } + + @Test + public void testDeleteAttribute() throws Exception { + AttributeDaoClient daoClient = new AttributeDaoClient(); + testName("deleteAttribute"); + /* Create an instance of AttributeGroup*/ + AttributeGroupTO attributeGroup = new AttributeGroupTO(); + AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup); + assertNotNull(resultAttributeGroup); + assertTrue(resultAttributeGroup.getId() > 0); + /* Create Attribute */ + AttributeTO ato = new AttributeTO(); + ato.setName("Attribute2"); + ato.setType("long"); + ato.setValue("13"); + ato.setGroupId(resultAttributeGroup.getId()); + AttributeTO newAttribute = daoClient.createAttribute(ato); + assertNotNull(newAttribute); + assertEquals(ato.getName(), newAttribute.getName()); + assertTrue(newAttribute.getId() != 0); daoClient.deleteAttribute(newAttribute.getId()); - } catch (Exception e) { - Assert.fail("Error deleting attribute"); - } - try { - daoClient.deleteAttributeGroup(resultAttributeGroup.getId()); - } catch (Exception e) { - Assert.fail("Error deleting attribute group"); - } passed(); } + + @Test + public void createAttributeGroup() throws Exception { + AttributeDaoClient daoClient = new AttributeDaoClient(); + testName("createAttributeGroup"); + /* Create an instance of AttributeGroup*/ + AttributeGroupTO attributeGroup = new AttributeGroupTO(); + AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup); + assertNotNull(resultAttributeGroup); + assertTrue(resultAttributeGroup.getId() > 0); + passed(); + } + /* + try { + daoClient.deleteAttributeGroup(resultAttributeGroup.getId()); + } catch (Exception e) { + Assert.fail("Error deleting attribute group"); + } + + */ } -- 2.39.2