Package org.jboss.forge.parser.java

Examples of org.jboss.forge.parser.java.Import


      JavaInterface bar = JavaParser.parse(JavaInterface.class, "package org.jboss.forge; public interface Bar{}");

      assertFalse(foo.hasImport(bar));
      assertFalse(bar.hasImport(foo));

      Import importBar = foo.addImport(bar);
      assertTrue(foo.hasImport(bar));
      assertFalse(bar.hasImport(foo));

      assertEquals("org.jboss.forge.Bar", importBar.getQualifiedName());
      assertEquals(importBar, foo.getImport(bar));

      foo.removeImport(bar);
      assertFalse(foo.hasImport(bar));
      assertFalse(bar.hasImport(foo));
View Full Code Here


   @Test
   public void testImportImport() throws Exception
   {
      JavaInterface foo = JavaParser.parse(JavaInterface.class, "public interface Foo{}");
      Import i = foo.addImport(getClass());

      foo.removeImport(getClass());
      Import i2 = foo.addImport(i);
      assertNotSame(i, i2);
      assertEquals(i.getQualifiedName(), i2.getQualifiedName());
   }
View Full Code Here

   @Test
   public void testImportNestedClass()
   {
      JavaClass javaClass = JavaParser.create(JavaClass.class);
      Import imprt = javaClass.addImport(NestedClass.class);

      Assert.assertEquals("org.jboss.forge.test.parser.java.NestedClassTest.NestedClass",
               imprt.getQualifiedName());
   }
View Full Code Here

               .getResourceAsStream("/org/jboss/forge/grammar/java/package-info.java");
      JavaPackageInfo javaPkg = JavaParser.parse(JavaPackageInfo.class, stream);
      assertEquals("org.jboss.forge.test.parser.java", javaPkg.getPackage());
      Assert.assertEquals("package-info", javaPkg.getName());
      Assert.assertNotNull(javaPkg.getImport("javax.xml.bind.annotation.XmlSchema"));
      Import XmlAccessTypeField = javaPkg.getImport("javax.xml.bind.annotation.XmlAccessType.FIELD");
      Assert.assertNotNull(XmlAccessTypeField);
      Assert.assertTrue(XmlAccessTypeField.isStatic());
      List<Annotation<JavaPackageInfo>> annotations = javaPkg.getAnnotations();
      Assert.assertEquals(2, annotations.size());
      Annotation<JavaPackageInfo> annotation = javaPkg.getAnnotation("XmlSchema");
      List<ValuePair> values = annotation.getValues();
      Assert.assertEquals(3, values.size());
View Full Code Here

    private static final String DEFAULT_IMPORT_CLASS = "Import";
    private static final String DEFAULT_IMPORT = DEFAULT_IMPORT_PACKAGE + "." + DEFAULT_IMPORT_CLASS;

    @Test
    public void testImportEqualsAnotherInstance() throws Exception {
        Import firstImport = buildImport(DEFAULT_IMPORT);
        Import secondImport = buildImport(DEFAULT_IMPORT);
        assertEquals(firstImport, secondImport);
        assertEquals(secondImport, firstImport);
    }
View Full Code Here

        assertEquals(secondImport, firstImport);
    }
   
    @Test
    public void testEqualsReturnsFalseForDifferentImport() throws Exception {
        Import classImport = buildImport(DEFAULT_IMPORT);
        Import interfaceImport = buildImport("org.jboss.forge.parser.java.impl.ImportImpl");
        assertFalse(classImport.equals(interfaceImport));
    }
View Full Code Here

        assertFalse(classImport.equals(interfaceImport));
    }
   
    @Test
    public void testEqualsIsReflexive() throws Exception {
        Import reflexiveImport = buildImport(DEFAULT_IMPORT);
        assertEquals(reflexiveImport, reflexiveImport);
    }
View Full Code Here

        assertEquals(reflexiveImport, reflexiveImport);
    }
   
    @Test
    public void testEqualsIsTransitive() throws Exception {
        Import firstImport = buildImport(DEFAULT_IMPORT);
        Import secondImport = buildImport(DEFAULT_IMPORT);
        Import thirdImport = buildImport(DEFAULT_IMPORT);
        assertEquals(firstImport, secondImport);
        assertEquals(secondImport, thirdImport);
        assertEquals(firstImport, thirdImport);
    }
View Full Code Here

        assertFalse(buildImport(DEFAULT_IMPORT).equals(null));
    }
   
    @Test
    public void testNotEqualsToDifferentClass() throws Exception {
        Import myImport = buildImport(DEFAULT_IMPORT);
        assertFalse(myImport.equals(DEFAULT_IMPORT));
    }
View Full Code Here

        assertFalse(myImport.equals(DEFAULT_IMPORT));
    }
   
    @Test
    public void testEqualsToDifferentImportImplementation() throws Exception {
        Import myImport = buildImport(DEFAULT_IMPORT);
        Import mockImport = new MockImportImpl(DEFAULT_IMPORT_PACKAGE, DEFAULT_IMPORT_CLASS);
        assertEquals(myImport, mockImport);
    }
View Full Code Here

TOP

Related Classes of org.jboss.forge.parser.java.Import

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.