@Test public void testMultipleKeys(@TuneProvider(JACKSON) Tune tune) { TypeSpec.Builder builder = TypeSpec.classBuilder("Test"); TypeModel model = mock(TypeModel.class); Map<String, String> values = new HashMap<>(); values.put("abc", "com.abc.xyz"); values.put("xyz", "com.xyz.abc"); SubTypeModel subTypeModel = new SubTypeModel("id", values); when(model.getSubTypes()).thenReturn(subTypeModel); new SubTypesRule(tune, null).process(builder, model); TypeSpec spec = builder.build(); assertEquals("Test", spec.name, "Wrong name found."); assertEquals(2, spec.annotations.size(), "Annotations found."); AnnotationSpec typeInfoAnnotationSpec = spec.annotations.get(0); verifyJsonTypeInfo(typeInfoAnnotationSpec); AnnotationSpec subTypesAnnotationSpec = spec.annotations.get(1); assertEquals(1, subTypesAnnotationSpec.members.size(), "More than one value found"); List<CodeBlock> subTypeValues = subTypesAnnotationSpec.members.get("value"); assertNotNull(subTypeValues); assertEquals(2, subTypeValues.size(), "Unexpected values found"); }
@Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getSubTypes() == null) { return; } tune.getAnnotatorStyles().forEach(style -> style.processSubTypeRule(typeSpec, typeModel)); }
SubTypesRule extends TypeRule { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getSubTypes() == null) { return; } tune.getAnnotatorStyles().forEach(style -> style.processSubTypeRule(typeSpec, typeModel)); } }
SubTypesRule extends TypeRule { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getSubTypes() == null) { return; } tune.getAnnotatorStyles().forEach(style -> style.processSubTypeRule(typeSpec, typeModel)); } SubTypesRule(Tune tune, MetaInfo metaInfo); }
SubTypesRule extends TypeRule { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getSubTypes() == null) { return; } tune.getAnnotatorStyles().forEach(style -> style.processSubTypeRule(typeSpec, typeModel)); } SubTypesRule(Tune tune, MetaInfo metaInfo); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel); }
SubTypesRule extends TypeRule { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { if (typeModel.getSubTypes() == null) { return; } tune.getAnnotatorStyles().forEach(style -> style.processSubTypeRule(typeSpec, typeModel)); } SubTypesRule(Tune tune, MetaInfo metaInfo); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel);  }