package model;

import model.TitanDSM;
import org.junit.Test;

import java.io.File;

import static org.junit.Assert.*;

public class TitanDSMTest {

    @Test
    public void testGetSize() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        assertEquals(30,dsm.getSize());
    }

    @Test
    public void testGetData() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        assertEquals(false, dsm.getData("entity_1","entity_2"));
    }

    @Test
    public void testSetData() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        dsm.setData(true,"entity_1","entity_2");
        assertEquals(true, dsm.getData("entity_1","entity_2"));
    }

    @Test
    public void testDeleteData() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        dsm.deleteData("entity_1");
        assertEquals(29,dsm.getSize());
    }

    @Test
    public void testGetName() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        assertEquals("entity_1",dsm.getName(0));
        assertEquals("entity",dsm.getName(0));
    }

    @Test
    public void testSetName() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        dsm.setName("NewName","entity_1");
        assertEquals("NewName",dsm.getName(0));
    }

    @Test
    public void testIsExist() throws Exception {

    }

    @Test
    public void testAddEntity() throws Exception {

    }

    @Test
    public void testLoadFromFile() throws Exception {

    }

    @Test
    public void testSaveToFile() throws Exception {
        TitanDSM dsm = new TitanDSM(30);
        File file = new File("a");
        dsm.setData(true,"entity_1","entity_2");
        dsm.saveToFile(file);
        TitanDSM dsm2 = new TitanDSM(file);
        assertEquals(dsm.getData("entity_1","entity_2"),dsm2.getData("entity_1","entity_2"));
    }

}
@@ -13,31 +13,8 @@
 l;%0A%0A
-import model.TitanDSM;%0A
 impo
@@ -37,30 +37,8 @@
 t;%0A%0A
-import java.io.File;%0A%0A
 impo
@@ -68,16 +68,38 @@
 ert.*;%0A%0A
+import java.io.File;%0A%0A
 public c
@@ -997,55 +997,8 @@
 ));%0A
-        assertEquals(%22entity%22,dsm.getName(0));%0A
     
@@ -1261,149 +1261,877 @@
 n %7B%0A
-%0A    %7D%0A%0A    @Test%0A    public void testAddEntity() throws Exception %7B%0A%0A    %7D%0A%0A    @Test%0A    public void testLoadFromFile() throws Exception %7B%0A
+        int size = 10;%0A        String existingString = %22entity_10%22;%0A        String nonExistingString = %22test%22;%0A        TitanDSM dsm = new TitanDSM(size);%0A        assertEquals(true, dsm.isExist(existingString));%0A        assertEquals(false, dsm.isExist(nonExistingString));%0A    %7D%0A%0A    @Test%0A    public void testAddEntity() throws Exception %7B%0A        int size = 10;%0A        TitanDSM dsm = new TitanDSM(size);%0A        dsm.addEntity();%0A        assertEquals(size + 1, dsm.getSize());%0A    %7D%0A%0A    @Test%0A    public void testLoadFromFile() throws Exception %7B%0A        int size = 10;%0A        String testString = %22edu.drexel.cs.rise.titan.action.RedrawAction%22;%0A        String pathName = %22./sample/titan/titan.dsm%22;%0A        File file = new File(pathName);%0A        TitanDSM dsm = new TitanDSM(size);%0A        dsm.loadFromFile(file);%0A        assertEquals(true, dsm.isExist(testString));
 %0A   
@@ -2495,10 +2495,9 @@
 ;%0A    %7D%0A
-%0A
 %7D

add titanDSM test function