Package net.riccardocossu.autodoc.parsers

Source Code of net.riccardocossu.autodoc.parsers.ClassParserTest

package net.riccardocossu.autodoc.parsers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import net.riccardocossu.autodoc.base.AnnotatedClass;
import net.riccardocossu.autodoc.jpa.JPAPlugin;
import net.riccardocossu.autodoc.test.model.AnnotatedTestEntity;
import net.riccardocossu.autodoc.test.model.NonJPATestEntity;
import net.riccardocossu.autodoc.test.model.optional.EntityWithEmbeddable;

import org.junit.Test;

public class ClassParserTest {

  @Test
  public void testSimple() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(AnnotatedTestEntity.class, factory);
    assertNotNull(res);
    assertEquals(1, res.getAnnotations().size());
    assertEquals(1, res.getFields().size());
    assertEquals(1, res.getMethods().size());
  }

  @Test
  public void testEmbedded() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(EntityWithEmbeddable.class, factory);
    assertNotNull(res);
    assertEquals(2, res.getAnnotations().size());
    assertEquals(1, res.getFields().size());
    assertEquals(0, res.getMethods().size());
  }

  @Test
  public void testNonJpa() {
    PluginFactory factory = new PluginFactory();
    factory.registerPlugin(new JPAPlugin());
    ClassParser parser = new ClassParser();
    AnnotatedClass res = parser.parse(NonJPATestEntity.class, factory);
    assertNull(res);
  }

}
TOP

Related Classes of net.riccardocossu.autodoc.parsers.ClassParserTest

TOP
Copyright © 2018 www.massapi.com. 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.