OutputSpecFactory { static ClassName toOutputClassName(ClassName specClassName) throws ParserException { String packageName = specClassName.packageName(); String name = specClassName.simpleName(); if (!isSpecClassName(specClassName)) { throw new ParserException( String.format( "Bad name for DataEnum interface! Name must end with '%s', found: %s", SUFFIX, name)); } String nameWithoutSuffix = name.substring(0, name.length() - SUFFIX.length()); return ClassName.get(packageName, nameWithoutSuffix); } private  OutputSpecFactory(); static OutputSpec create(Spec spec);  }
@Test public void shouldRemoveDataEnumInterfaceSuffix() throws Exception { assertThat( OutputSpecFactory.toOutputClassName(ClassName.get("com.spotify", "My_dataenum")), is(ClassName.get("com.spotify", "My"))); }
@Test public void shouldThrowForNonDataenumClassName() throws Exception { assertThatThrownBy( () -> OutputSpecFactory.toOutputClassName(ClassName.get("com.spotify", "My"))) .isInstanceOf(ParserException.class) .hasMessageContaining("Bad name"); }