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;
@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();
}
}