-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/exportToXML #62
Conversation
|
||
@NoArgsConstructor | ||
@XmlRootElement(name = "instructions") | ||
abstract class JFixturesResultImpl implements JFixturesResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename it to JFixturesResultBase
since it is not an implementation but an abstract class?
abstract class JFixturesResultImpl implements JFixturesResult { | ||
private String fixturesFolder; | ||
|
||
@Setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need @Setter
? Can't we put XML related annotation on getter(getInstructions()
method) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If getter is an allowed mechanism, then, perhaos, we can remove this field at all or leave only getInstructions()
?
@@ -24,6 +26,11 @@ public FixtureValue(Object value) { | |||
} | |||
} | |||
|
|||
@XmlValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to serialize the type
field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean
@XmlValue private final Object value;
@@ -24,6 +26,11 @@ public FixtureValue(Object value) { | |||
} | |||
} | |||
|
|||
@XmlValue | |||
public String getStringValue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it serialize if the method is defined like Object getValue()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`fixturesResult.asString() == EXPECTED_XML
| |
| java.lang.NullPointerException
com.github.vkorobkov.jfixtures.fluent.impl.XmlJFixturesResultImpl@548a24a
at com.github.vkorobkov.jfixtures.fluent.impl.XmlJFixturesResultImplTest.processes fixtures to string(XmlJFixturesResultImplTest.groovy:57)`
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@XmlRootElement(name = "instructions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can @XmlRootElement
be moved into XmlJFixturesResultImpl
?
|
||
@SneakyThrows | ||
private Marshaller getMarshaller() { | ||
val jaxbContext = JAXBContext.newInstance(JFixturesResultBase.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be instantiated like JAXBContext.newInstance(getClass())
?
@@ -29,6 +31,11 @@ public String toString() { | |||
return String.valueOf(value); | |||
} | |||
|
|||
@XmlValue | |||
String getValueAsString() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to getXmlRepresentation
?
@@ -4,6 +4,8 @@ | |||
import lombok.EqualsAndHashCode; | |||
import lombok.Getter; | |||
|
|||
import javax.xml.bind.annotation.XmlValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we don't add type
field into result XML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as a attribute/tag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it could be <value type="SQL">DEFAULT</value>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor remarks and questions left
@@ -4,6 +4,8 @@ | |||
import lombok.EqualsAndHashCode; | |||
import lombok.Getter; | |||
|
|||
import javax.xml.bind.annotation.XmlValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as a attribute/tag)
@@ -4,6 +4,8 @@ | |||
import lombok.EqualsAndHashCode; | |||
import lombok.Getter; | |||
|
|||
import javax.xml.bind.annotation.XmlValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it could be <value type="SQL">DEFAULT</value>
abstract class JFixturesResultBase implements JFixturesResult { | ||
private String fixturesFolder; | ||
|
||
@XmlElements({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this XML specific annotation to XmlJFixturesResultImpl
since the base class should not know about the implementation and technical details of its children?
@Override
@XmlElements( .... )
List<Instruction> getInstructions() {
return super.getInstructions();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks amazing! 🍰
No description provided.