@Test public void testNormalSuperClass(@TuneProvider Tune tune) { String fullPackage = "com.flipkart.lyrics.test.classes"; String className = "SuperClass"; VariableModel variableModel = new VariableModel(fullPackage + "." + className); TypeModel model = mock(TypeModel.class); when(model.getExtendsType()).thenReturn(variableModel); TypeSpec.Builder builder = TypeSpec.classBuilder("Test"); MetaInfo metaInfo = new MetaInfo(null, null, new HashMap<>()); new SuperClassHandler(tune, metaInfo, null).process(builder, model); TypeSpec spec = builder.build(); assertEquals("Test", spec.name, "Wrong class name found"); TypeName superclass = spec.superclass; assertTrue(superclass instanceof ClassName); ClassName superClassName = (ClassName) superclass; assertAll("Class and package name assertions", () -> assertEquals(fullPackage, superClassName.packageName()), () -> assertEquals(className, superClassName.simpleName())); }
@Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getExtendsType() == null) { return; } TypeName extendsType = getResolvedTypeName(typeModel.getExtendsType(), metaInfo.getGenericVariables(), tune.getChords()); typeSpec.superclass(extendsType); }
SuperClassHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getExtendsType() == null) { return; } TypeName extendsType = getResolvedTypeName(typeModel.getExtendsType(), metaInfo.getGenericVariables(), tune.getChords()); typeSpec.superclass(extendsType); } }
SuperClassHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getExtendsType() == null) { return; } TypeName extendsType = getResolvedTypeName(typeModel.getExtendsType(), metaInfo.getGenericVariables(), tune.getChords()); typeSpec.superclass(extendsType); } SuperClassHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); }
SuperClassHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getExtendsType() == null) { return; } TypeName extendsType = getResolvedTypeName(typeModel.getExtendsType(), metaInfo.getGenericVariables(), tune.getChords()); typeSpec.superclass(extendsType); } SuperClassHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel); }
SuperClassHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getExtendsType() == null) { return; } TypeName extendsType = getResolvedTypeName(typeModel.getExtendsType(), metaInfo.getGenericVariables(), tune.getChords()); typeSpec.superclass(extendsType); } SuperClassHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel);  }