Skip to content

Commit

Permalink
Fixed unwanted VAST XML linebreaks (#1952)
Browse files Browse the repository at this point in the history
  • Loading branch information
And1sS authored Jul 15, 2022
1 parent a264a2b commit 6f5f4a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/prebid/server/vast/VastModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public String createBidVastXml(String bidder,
private static String resolveVastXmlFrom(String bidAdm, String bidNurl) {
return StringUtils.isEmpty(bidAdm) && bidNurl != null
? """
<VAST version="3.0"><Ad><Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>
<Creatives></Creatives>
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>\
<Creatives></Creatives>\
</Wrapper></Ad></VAST>""".formatted(bidNurl)
: bidAdm;
}
Expand Down
34 changes: 20 additions & 14 deletions src/test/java/org/prebid/server/vast/VastModifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ public void modifyVastXmlShouldModifyVastAndAppendUrl() {
INTEGRATION);

// then
final String modifiedVast = "<VAST version=\"3.0\"><Ad><Wrapper><AdSystem>prebid.org wrapper</AdSystem>"
+ "<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI><Impression></Impression>"
+ "<Impression><![CDATA[http://external-url/event]]></Impression>"
+ "<Creatives></Creatives></Wrapper></Ad></VAST>";
final String modifiedVast =
"""
<VAST version="3.0"><Ad><Wrapper><AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI><Impression></Impression>\
<Impression><![CDATA[http://external-url/event]]></Impression><Creatives>\
</Creatives></Wrapper></Ad></VAST>\
""";

assertThat(result).isEqualTo(new TextNode(modifiedVast));
}
Expand Down Expand Up @@ -341,20 +344,23 @@ private static TextNode nodeAdm() {
}

public static String adm() {
return "<VAST version=\"3.0\"><Ad><Wrapper>"
+ "<AdSystem>prebid.org wrapper</AdSystem>"
+ "<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI>"
+ "<Impression></Impression><Creatives></Creatives>"
+ "</Wrapper></Ad></VAST>";
return """
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem><VASTAdTagURI>\
<![CDATA[adm2]]></VASTAdTagURI><Impression>\
</Impression><Creatives></Creatives>\
</Wrapper></Ad></VAST>\
""";
}

private static String modifiedAdm(String bidNurl) {
return """
<VAST version="3.0"><Ad><Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>
<Creatives></Creatives>
</Wrapper></Ad></VAST>""".formatted(bidNurl);
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>\
<Creatives></Creatives>\
</Wrapper></Ad></VAST>\
""".formatted(bidNurl);
}

private static EventsContext givenEventsContext(boolean accountEnabled) {
Expand Down

0 comments on commit 6f5f4a0

Please sign in to comment.