Added CDNSslUri to CDNContainer class, updated json and unit tests

This commit is contained in:
Jeremy Daggett 2012-11-09 14:24:55 -08:00
parent 3aa47bb499
commit e1ab195056
3 changed files with 55 additions and 33 deletions

View File

@ -40,12 +40,13 @@ public class CDNContainer implements Comparable<CDNContainer> {
public static class Builder { public static class Builder {
protected String name; protected String name;
protected boolean cdnEnabled; protected boolean cdn_enabled;
protected boolean log_retention;
protected long ttl; protected long ttl;
protected URI CDNUri; protected URI cdn_uri;
protected String referrerAcl; protected URI cdn_ssl_uri;
protected String useragentAcl; protected String referrer_acl;
protected boolean logRetention; protected String useragent_acl;
/** /**
* @see CDNContainer#getName() * @see CDNContainer#getName()
@ -58,8 +59,8 @@ public class CDNContainer implements Comparable<CDNContainer> {
/** /**
* @see CDNContainer#isCDNEnabled() * @see CDNContainer#isCDNEnabled()
*/ */
public Builder CDNEnabled(boolean cdnEnabled) { public Builder CDNEnabled(boolean cdn_enabled) {
this.cdnEnabled = cdnEnabled; this.cdn_enabled = cdn_enabled;
return this; return this;
} }
@ -74,61 +75,71 @@ public class CDNContainer implements Comparable<CDNContainer> {
/** /**
* @see CDNContainer#getCDNUri() * @see CDNContainer#getCDNUri()
*/ */
public Builder CDNUri(URI CDNUri) { public Builder CDNUri(URI cdn_uri) {
this.CDNUri = CDNUri; this.cdn_uri = cdn_uri;
return this; return this;
} }
/**
* @see CDNContainer#getCDNSslUri()
*/
public Builder CDNSslUri(URI cdn_ssl_uri) {
this.cdn_ssl_uri = cdn_ssl_uri;
return this;
}
/** /**
* @see CDNContainer#getReferrerAcl() * @see CDNContainer#getReferrerAcl()
*/ */
public Builder referrerAcl(String referrerAcl) { public Builder referrerAcl(String referrer_acl) {
this.referrerAcl = referrerAcl; this.referrer_acl = referrer_acl;
return this; return this;
} }
/** /**
* @see CDNContainer#getUseragentAcl() * @see CDNContainer#getUseragentAcl()
*/ */
public Builder useragent_acl(String useragentAcl) { public Builder useragentAcl(String useragent_acl) {
this.useragentAcl = useragentAcl; this.useragent_acl = useragent_acl;
return this; return this;
} }
/** /**
* @see CDNContainer#isLogRetention() * @see CDNContainer#isLogRetention()
*/ */
public Builder logRetention(boolean logRetention) { public Builder logRetention(boolean log_retention) {
this.logRetention = logRetention; this.log_retention = log_retention;
return this; return this;
} }
public CDNContainer build() { public CDNContainer build() {
return new CDNContainer(name, cdnEnabled, ttl, CDNUri, referrerAcl, useragentAcl, logRetention); return new CDNContainer(name, cdn_enabled, ttl, cdn_uri, cdn_ssl_uri, referrer_acl, useragent_acl, log_retention);
} }
public Builder fromCDNContainer(CDNContainer in) { public Builder fromCDNContainer(CDNContainer in) {
return this.name(in.getName()).CDNEnabled(in.isCDNEnabled()).ttl(in.getTTL()).CDNUri(in.getCDNUri()) return this.name(in.getName()).CDNEnabled(in.isCDNEnabled()).ttl(in.getTTL())
.referrerAcl(in.getReferrerAcl()).useragent_acl(in.getUseragentAcl()) .CDNUri(in.getCDNUri()).CDNSslUri(in.getCDNSslUri()).referrerAcl(in.getReferrerAcl())
.logRetention(in.isLogRetention()); .useragentAcl(in.getUseragentAcl()).logRetention(in.isLogRetention());
} }
} }
private final String name; private final String name;
private final boolean cdnEnabled; private final boolean cdnEnabled;
private final boolean logRetention;
private final long ttl; private final long ttl;
private final URI CDNUri; private final URI CDNUri;
private final URI CDNSslUri;
private final String referrerAcl; private final String referrerAcl;
private final String useragentAcl; private final String useragentAcl;
private final boolean logRetention;
@ConstructorProperties({ "name", "cdn_enabled", "ttl", "cdn_uri", "referrer_acl", "useragent_acl", "log_retention" }) @ConstructorProperties({ "name", "cdn_enabled", "ttl", "cdn_uri", "cdn_ssl_uri", "referrer_acl", "useragent_acl", "log_retention" })
protected CDNContainer(@Nullable String name, boolean cdnEnabled, long ttl, @Nullable URI CDNUri, protected CDNContainer(@Nullable String name, boolean cdnEnabled, long ttl, @Nullable URI CDNUri,
@Nullable String referrerAcl, @Nullable String useragentAcl, boolean logRetention) { @Nullable URI CDNSslUri, @Nullable String referrerAcl, @Nullable String useragentAcl, boolean logRetention) {
this.name = Strings.emptyToNull(name); this.name = Strings.emptyToNull(name);
this.cdnEnabled = cdnEnabled; this.cdnEnabled = cdnEnabled;
this.ttl = ttl; this.ttl = ttl;
this.CDNUri = CDNUri; this.CDNUri = CDNUri;
this.CDNSslUri = CDNSslUri;
this.referrerAcl = Strings.emptyToNull(referrerAcl); this.referrerAcl = Strings.emptyToNull(referrerAcl);
this.useragentAcl = Strings.emptyToNull(useragentAcl); this.useragentAcl = Strings.emptyToNull(useragentAcl);
this.logRetention = logRetention; this.logRetention = logRetention;
@ -157,6 +168,11 @@ public class CDNContainer implements Comparable<CDNContainer> {
return this.CDNUri; return this.CDNUri;
} }
@Nullable
public URI getCDNSslUri() {
return this.CDNSslUri;
}
@Nullable @Nullable
public String getReferrerAcl() { public String getReferrerAcl() {
return this.referrerAcl; return this.referrerAcl;
@ -188,8 +204,8 @@ public class CDNContainer implements Comparable<CDNContainer> {
protected ToStringHelper string() { protected ToStringHelper string() {
return Objects.toStringHelper(this).omitNullValues().add("name", name).add("cdnEnabled", cdnEnabled) return Objects.toStringHelper(this).omitNullValues().add("name", name).add("cdnEnabled", cdnEnabled)
.add("ttl", ttl).add("CDNUri", CDNUri).add("referrerAcl", referrerAcl).add("useragentAcl", useragentAcl) .add("ttl", ttl).add("CDNUri", CDNUri).add("CDNSslUri", CDNSslUri).add("referrerAcl", referrerAcl)
.add("logRetention", logRetention); .add("useragentAcl", useragentAcl).add("logRetention", logRetention);
} }
@Override @Override

View File

@ -45,11 +45,17 @@ public class CDNContainersTest extends BaseItemParserTest<FluentIterable<CDNCont
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public FluentIterable<CDNContainer> expected() { public FluentIterable<CDNContainer> expected() {
return FluentIterable.from(ImmutableSet.of( return FluentIterable.from(ImmutableSet.of(
CDNContainer.builder().name("hpcloud-blobstore.testCDNOperationsContainerWithCDN").CDNEnabled(false) CDNContainer.builder().name("hpcloud-blobstore.testCDNOperationsContainerWithCDN").CDNEnabled(false).ttl(3600)
.ttl(3600).CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build(), .CDNUri(URI.create("http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com"))
CDNContainer.builder().name("hpcloud-blobstore5").CDNEnabled(true).ttl(28800) .CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2"))
.CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build(), .build(),
CDNContainer.builder().name("hpcloud-cfcdnint.testCDNOperationsContainerWithCDN").CDNEnabled(false) CDNContainer.builder().name("hpcloud-blobstore5").CDNEnabled(true).ttl(28800)
.ttl(3600).CDNUri(URI.create("https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/")).build())); .CDNUri(URI.create("http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com"))
.CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2"))
.build(),
CDNContainer.builder().name("hpcloud-cfcdnint.testCDNOperationsContainerWithCDN").CDNEnabled(false).ttl(3600)
.CDNUri(URI.create("http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com"))
.CDNSslUri(URI.create("https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2"))
.build()));
} }
} }

View File

@ -1,5 +1,5 @@
[ [
{"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, {"name":"hpcloud-blobstore.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h10cdf69e2913a87afe9ce721ceb35ca5.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h10cdf69e2913a87afe9ce721ceb35ca5/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"},
{"name":"hpcloud-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"}, {"name":"hpcloud-blobstore5","cdn_enabled":"true","ttl":28800,"cdn_uri":"http://h0bc2984e4ad8f8bec0ebf5b147c9fe55.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h0bc2984e4ad8f8bec0ebf5b147c9fe55/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"},
{"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"https://cdnmgmt.hpcloud.net:8080/v1/AUTH_test/","referrer_acl":"","useragent_acl":"", "log_retention":"false"} {"name":"hpcloud-cfcdnint.testCDNOperationsContainerWithCDN","cdn_enabled":"false","ttl":3600,"cdn_uri":"http://h82d1ae1ee2ada5151c60e33f097294c2.cdn.hpcloudsvc.com","cdn_ssl_uri":"https://a248.e.akamai.net/cdn.hpcloudsvc.com/h82d1ae1ee2ada5151c60e33f097294c2/aw2","referrer_acl":"","useragent_acl":"", "log_retention":"false"}
] ]