@Test public void fields() { final String name = "error"; final Collection<String> types = new StickyList<>("Error"); MatcherAssert.assertThat( new JavaClass( name, types, new ObjectBody( new StickyList<>(new Attribute("Text", "msg")), new StickyList<>(), new StickyList<>() ) ).code(), new InputHasContent( Matchers.stringContainsInOrder( new StickyList<>( "public final class", name, "implements Error", "{", "private final Text msg;", new UncheckedText( new FormattedText("public %s(final Text msg)", name) ).asString(), "{", "this.msg = msg;", "}", "}" ) ) ) ); }
@Override public Input code() { return new InputOf( new FormattedText( "%s\n\npublic final class %s implements %s {\n %s\n}\n", "package eo;", this.name, new UncheckedText( new JoinedText(", ", this.ifaces) ).asString(), this.body.java(this.name).replace("\n", "\n ") ) ); }
JavaClass implements JavaFile { @Override public Input code() { return new InputOf( new FormattedText( "%s\n\npublic final class %s implements %s {\n %s\n}\n", "package eo;", this.name, new UncheckedText( new JoinedText(", ", this.ifaces) ).asString(), this.body.java(this.name).replace("\n", "\n ") ) ); } }
JavaClass implements JavaFile { @Override public Input code() { return new InputOf( new FormattedText( "%s\n\npublic final class %s implements %s {\n %s\n}\n", "package eo;", this.name, new UncheckedText( new JoinedText(", ", this.ifaces) ).asString(), this.body.java(this.name).replace("\n", "\n ") ) ); } @SuppressWarnings("checkstyle:parameternumbercheck")  JavaClass(final String name, final Collection<String> ifaces,
        final ObjectBody body); }
JavaClass implements JavaFile { @Override public Input code() { return new InputOf( new FormattedText( "%s\n\npublic final class %s implements %s {\n %s\n}\n", "package eo;", this.name, new UncheckedText( new JoinedText(", ", this.ifaces) ).asString(), this.body.java(this.name).replace("\n", "\n ") ) ); } @SuppressWarnings("checkstyle:parameternumbercheck")  JavaClass(final String name, final Collection<String> ifaces,
        final ObjectBody body); @Override String path(); @Override Input code(); }
JavaClass implements JavaFile { @Override public Input code() { return new InputOf( new FormattedText( "%s\n\npublic final class %s implements %s {\n %s\n}\n", "package eo;", this.name, new UncheckedText( new JoinedText(", ", this.ifaces) ).asString(), this.body.java(this.name).replace("\n", "\n ") ) ); } @SuppressWarnings("checkstyle:parameternumbercheck")  JavaClass(final String name, final Collection<String> ifaces,
        final ObjectBody body); @Override String path(); @Override Input code();  }