package test.methodinterceptors.multipleinterceptors;

import java.util.Collections;

import org.testng.Assert;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.annotations.Test;

import test.SimpleBaseTest;

public class MultipleInterceptorsTest extends SimpleBaseTest {
    
    @Test
    public void testMultipleInterceptors(){
      TestNG tng = create(FooTest.class);
      tng.setMethodInterceptor(new FirstInterceptor());
      tng.setMethodInterceptor(new SecondInterceptor());
      tng.setMethodInterceptor(new ThirdInterceptor());
      TestListenerAdapter tla = new TestListenerAdapter();
      tng.addListener(tla);
      tng.run();
      Assert.assertEquals(tla.getPassedTests().size(), 1);
      Assert.assertEquals(tla.getPassedTests().get(0).getName(), "d");
    }

    @Test
    public void testMultipleInterceptorsWithPreserveOrder() {
      TestNG tng = create();
      tng.setTestSuites(Collections.singletonList(
          getPathToResource("/methodinterceptors/multipleinterceptors/multiple-interceptors.xml")));
      TestListenerAdapter tla = new TestListenerAdapter();
      tng.addListener(tla);
      tng.run();
      // Interceptor are called twice => GITHUB #154
      Assert.assertEquals(tla.getPassedTests().get(0).getMethod().getDescription(), "abcabc");
    }
}

@@ -1171,61 +1171,8 @@
 ();%0A
-      // Interceptor are called twice =%3E GITHUB #154%0A
     
@@ -1255,19 +1255,16 @@
 (), %22abc
-abc
 %22);%0A    

Fix test :]