@Test
public void testClassNameParsing() {

    assertThat(Compilations.getPublicClassName(
            "public class A { public static void main(String[] args) {} } class B {}"))
                    .isEqualTo("A");
    assertThat(Compilations.getPublicClassName("public class X extends Object {}"))
            .isEqualTo("X");
    assertThat(Compilations.getPublicClassName(
            "public class X extends Object {} public class Y extends Object {}"))
                    .isEqualTo("X");
    assertThat(Compilations
            .getPublicClassName("class X extends Object {} public class Y extends Object {}"))
                    .isEqualTo("Y");
    assertThat(Compilations
            .getPublicClassName("class X extends Object {}\npublic class Y extends Object {}"))
                    .isEqualTo("Y");
    assertThat(Compilations
            .getPublicClassName("class X extends Object {}public class Y extends Object {}"))
                    .isEqualTo("Y");
    assertThat(Compilations.getPublicClassName("class X extends Object {}")).isEqualTo("");
}