Package org.jboss.forge.roaster.model.source

Examples of org.jboss.forge.roaster.model.source.Import


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

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


      JavaInterfaceSource bar = Roaster.parse(JavaInterfaceSource.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
   {
      JavaInterfaceSource foo = Roaster.parse(JavaInterfaceSource.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

      for (Type type : superTypes)
      {
         String name = JDTHelper.getTypeName(type);
         if (Types.isSimpleName(name) && this.hasImport(name))
         {
            Import imprt = this.getImport(name);
            String pkg = imprt.getPackage();
            if (!Strings.isNullOrEmpty(pkg))
            {
               name = pkg + "." + name;
            }
         }
View Full Code Here

               .getResourceAsStream("/org/jboss/forge/grammar/java/package-info.java");
      JavaPackageInfoSource javaPkg = Roaster.parse(JavaPackageInfoSource.class, stream);
      assertEquals("org.jboss.forge.test.roaster.model", 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<AnnotationSource<JavaPackageInfoSource>> annotations = javaPkg.getAnnotations();
      Assert.assertEquals(2, annotations.size());
      Annotation<JavaPackageInfoSource> 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.roaster.model.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

TOP

Related Classes of org.jboss.forge.roaster.model.source.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.