aboutsummaryrefslogtreecommitdiffstats
path: root/javaparser-testing/src/test/java/com/github/javaparser/ast/nodeTypes/NodeWithOptionalScopeTest.java
blob: ad7e8bd7e26b5bb68a6249d6cbe2aee2747b954e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.github.javaparser.ast.nodeTypes;

import com.github.javaparser.ast.expr.*;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class NodeWithOptionalScopeTest {

    @Test
    public void commonExpressionWhichHaveInterfaceNodeWithOptionalScope() {
        NodeWithOptionalScope methodCallExpr = new MethodCallExpr(new NameExpr("A"), "call");
        NodeWithOptionalScope objectCreationExpr = new ObjectCreationExpr();

        assertTrue(methodCallExpr.getScope().isPresent());
        assertFalse(objectCreationExpr.getScope().isPresent());
    }

    @Test
    public void removeScope() {
        MethodCallExpr methodCallExpr = new MethodCallExpr(new NameExpr("A"), "method");

        methodCallExpr.removeScope();

        assertFalse(methodCallExpr.getScope().isPresent());
    }
}