File tree Expand file tree Collapse file tree 2 files changed +45
-3
lines changed
annot/src/test/java/com/predic8/membrane/annot Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,39 @@ public class DemoElement {
2929 );
3030 }
3131
32+ @ Test
33+ public void attribute () {
34+ var sources = splitSources (MC_MAIN_DEMO + """
35+ package com.predic8.membrane.demo;
36+ import com.predic8.membrane.annot.*;
37+ import java.util.List;
38+ @MCElement(name="demo")
39+ public class DemoElement {
40+ public String attr;
41+
42+ public String getAttr() {
43+ return attr;
44+ }
45+
46+ @MCAttribute
47+ public void setAttr(String attr) {
48+ this.attr = attr;
49+ }
50+ }
51+ """ );
52+ var result = CompilerHelper .compile (sources , false );
53+ assertCompilerResult (true , result );
54+
55+ assertStructure (
56+ parseYAML (result , """
57+ demo:
58+ attr: here
59+ """ ),
60+ clazz ("DemoElement" ,
61+ property ("attr" , value ("here" )))
62+ );
63+ }
64+
3265 @ Test
3366 public void singleChild () {
3467 var sources = splitSources (MC_MAIN_DEMO + """
@@ -37,14 +70,14 @@ public void singleChild() {
3770 import java.util.List;
3871 @MCElement(name="demo")
3972 public class DemoElement {
40- ChildElement child;
73+ Child1Element child;
4174
42- public ChildElement getChild() {
75+ public Child1Element getChild() {
4376 return child;
4477 }
4578
4679 @MCChildElement
47- public void setChild(ChildElement child) {
80+ public void setChild(Child1Element child) {
4881 this.child = child;
4982 }
5083 }
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ public void assertStructure(Object bean) {
3535 };
3636 }
3737
38+ public static Asserter value (Object value ) {
39+ return new Asserter () {
40+ @ Override
41+ public void assertStructure (Object bean ) {
42+ assertEquals (value , bean );
43+ }
44+ };
45+ }
46+
3847 public static Property property (String name , Asserter asserter ) {
3948 return new Property () {
4049 @ Override
You can’t perform that action at this time.
0 commit comments