package cruise.umple.implementation.java.innerClass;

import org.junit.*;
import cruise.umple.implementation.TemplateTest;
import cruise.umple.util.SampleFileWriter;

import java.util.Map;
import cruise.umple.compiler.UmpleClass;
import cruise.umple.compiler.UmpleFile;
import cruise.umple.compiler.UmpleModel;

public class InnerClassTest extends TemplateTest {

  @Before
  public void setUp()
  {
    pathToInput = SampleFileWriter.rationalize("test/cruise/umple/implementation/java/innerClass");
    pathToRoot = SampleFileWriter.rationalize("../cruise.umple");
    language = null;
    suboptions = null;
    languagePath = "java";
    umpleParserName = "cruise.umple.compiler.UmpleInternalParser";
    aTracer = null;
    tracerPath = null;
  }
	
  @Test
  public void TestInnerStaticClass()
  {
    assertUmpleTemplateFor("/innerStatic.ump", "/innerStatic.java.txt", "OuterClass_1");
  }

  @Test
  public void TestInnerNonStaticClass()
  {
    assertUmpleTemplateFor("/innerNonStatic.ump", "/InnerNotStatic.java.txt", "OuterClass_2");
  }
  @Test
  public void TestInnerStaticAndNonStaticClass()
  {
    assertUmpleTemplateFor("/innerClasses.ump",  "/innerClasses.java.txt", "OuterClass_3");
  }

  @Test
  public void TestNoPackageNameForInnerElement()
  {
    UmpleFile uFile = new UmpleFile(pathToInput+"/OuterClassWithNameSpace.ump");
		UmpleModel umpleModel = new UmpleModel(uFile);
		umpleModel.run();
		umpleModel.generate();
		Map<String, String> map= umpleModel.getGeneratedCode();
		String generatedCodeforClass = map.get("OuterClassWithNameSpace");
		//if there is only one import-statement, its split should generate 2 strings:
		Assert.assertEquals(generatedCodeforClass.split("package com.umple.innerClasses").length , 2);
   // assertUmpleTemplateFor("/innerClasses.ump",  "/innerClasses.java.txt", "OuterClass_3");
  }

  @After
  public void tearDown()
  {
    SampleFileWriter.destroy(pathToInput + "/OuterClass_1.java");
    SampleFileWriter.destroy(pathToInput + "/OuterClass_2.java");
    SampleFileWriter.destroy(pathToInput + "/OuterClass_3.java");
    SampleFileWriter.destroy(pathToInput + "/com");
  }

}




@@ -1387,18 +1387,20 @@
 ump%22);%0D%0A
-%09%09
+    
 UmpleMod
@@ -1435,26 +1435,28 @@
 el(uFile);%0D%0A
-%09%09
+    
 umpleModel.r
@@ -1462,18 +1462,20 @@
 run();%0D%0A
-%09%09
+    
 umpleMod
@@ -1490,18 +1490,20 @@
 ate();%0D%0A
-%09%09
+    
 Map%3CStri
@@ -1551,18 +1551,20 @@
 ode();%0D%0A
-%09%09
+    
 String g
@@ -1623,18 +1623,20 @@
 ace%22);%0D%0A
-%09%09
+    
 //if the
@@ -1710,10 +1710,12 @@
 s:%0D%0A
-%09%09
+    
 Asse
@@ -1806,16 +1806,17 @@
  , 2);%0D%0A
+ 
    // as

clean files.