]> git.uio.no Git - ifi-stolz-refaktor.git/commitdiff
Changing test to utilize the hamcrest instanceOf matcher.
authorErlend Kristiansen <erlenkr@ifi.uio.no>
Fri, 20 Dec 2013 20:53:38 +0000 (21:53 +0100)
committerErlend Kristiansen <erlenkr@ifi.uio.no>
Fri, 20 Dec 2013 20:53:38 +0000 (21:53 +0100)
software/no.uio.ifi.refaktor.tests/.classpath
software/no.uio.ifi.refaktor.tests/src/no/uio/ifi/refaktor/tests/SearchBasedExtractAndMoveMethodAnalyzerTest.java

index ad32c83a7885b8953a938b41df3b4fd4fe1aae01..23f11b11ae71130babce02215f31617a37d403ad 100644 (file)
@@ -3,5 +3,6 @@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index d02b01e4ad8654676fc701ddbb2b06f875f93adc..f9bc37637ce21e98b4abb5f6bec79c13888229f4 100644 (file)
@@ -1,7 +1,9 @@
 package no.uio.ifi.refaktor.tests;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
 import no.uio.ifi.refaktor.analyze.Analyzer;
 import no.uio.ifi.refaktor.analyze.FavorNoUnfixesAnalysisResultComparator;
 import no.uio.ifi.refaktor.analyze.NoTargetFoundException;
@@ -50,15 +52,20 @@ public class SearchBasedExtractAndMoveMethodAnalyzerTest {
        @Test
        public void testSimpleMethod() throws JavaModelException {
                IMethod method = getTestDataMethod("simpleMethod");
+
                SearchBasedExtractAndMoveMethodAnalyzer analyzer = new SearchBasedExtractAndMoveMethodAnalyzer(method);
                analyzer.analyze();
+
                int methodOffset = method.getSourceRange().getOffset();
                CompilationUnitTextSelection textSelection = new CompilationUnitTextSelection(method.getCompilationUnit(), methodOffset + 69, 10);
                assertEquals(textSelection, analyzer.getTextSelection());
+
                ASTNode coveredNode = textSelection.getCoveredNode();
-               assertTrue(coveredNode instanceof ExpressionStatement);
+               assertThat(coveredNode, instanceOf(ExpressionStatement.class));
+
                ExpressionStatement expressionStatement = (ExpressionStatement) coveredNode;
-               assertTrue(expressionStatement.getExpression() instanceof MethodInvocation);
+               assertThat(expressionStatement.getExpression(), instanceOf(MethodInvocation.class));
+
                MethodInvocation methodInvocation = (MethodInvocation) expressionStatement.getExpression();
                Prefix prefix = new Prefix(methodInvocation);
                assertTrue(prefix.getVariableBindingOfFirstExpression().isEqualTo(analyzer.calculateOriginalTarget()));
@@ -67,15 +74,20 @@ public class SearchBasedExtractAndMoveMethodAnalyzerTest {
        @Test
        public void testSearchableMethodFavorNoUnfixes() throws Exception {
                IMethod method = getTestDataMethod("searchableMethod");
+
                SearchBasedExtractAndMoveMethodAnalyzer analyzer = new SearchBasedExtractAndMoveMethodAnalyzer(method, new FavorNoUnfixesAnalysisResultComparator());
                analyzer.analyze();
+
                int methodOffset = method.getSourceRange().getOffset();
                CompilationUnitTextSelection textSelection = new CompilationUnitTextSelection(method.getCompilationUnit(), methodOffset + 100, 31);
-               assertEquals(textSelection, analyzer.getTextSelection());
+               assertEquals(textSelection, analyzer.getTextSelection()); 
+
                ASTNode coveredNode = textSelection.getCoveredNode();
-               assertTrue(coveredNode instanceof ExpressionStatement);
+               assertThat(coveredNode, instanceOf(ExpressionStatement.class));
+
                ExpressionStatement expressionStatement = (ExpressionStatement) coveredNode;
-               assertTrue(expressionStatement.getExpression() instanceof MethodInvocation);
+               assertThat(expressionStatement.getExpression(), instanceOf(MethodInvocation.class));
+
                MethodInvocation methodInvocation = (MethodInvocation) expressionStatement.getExpression();
                Prefix prefix = new Prefix(methodInvocation);
                assertTrue(prefix.getVariableBindingOfFirstExpression().isEqualTo(analyzer.calculateOriginalTarget()));