mirror of https://github.com/apache/jclouds.git
converted RegionToTerritories to a multimap and normalized use of IdAndName
This commit is contained in:
parent
25a0b73436
commit
8c18f3ba1b
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.ultradns.ws;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.POST;
|
||||
|
@ -30,8 +29,7 @@ import org.jclouds.rest.annotations.PayloadParam;
|
|||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.features.DirectionalGroupApi;
|
||||
import org.jclouds.ultradns.ws.features.DirectionalPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
|
@ -43,6 +41,8 @@ import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
|||
import org.jclouds.ultradns.ws.xml.AccountHandler;
|
||||
import org.jclouds.ultradns.ws.xml.RegionListHandler;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Provides access to Neustar UltraDNS via the SOAP API
|
||||
* <p/>
|
||||
|
@ -60,7 +60,7 @@ public interface UltraDNSWSApi extends Closeable {
|
|||
@POST
|
||||
@XMLResponseParser(AccountHandler.class)
|
||||
@Payload("<v01:getAccountsListOfUser/>")
|
||||
Account getCurrentAccount();
|
||||
IdAndName getCurrentAccount();
|
||||
|
||||
/**
|
||||
* Lists the directional regions available in the account.
|
||||
|
@ -69,7 +69,7 @@ public interface UltraDNSWSApi extends Closeable {
|
|||
@POST
|
||||
@XMLResponseParser(RegionListHandler.class)
|
||||
@Payload("<v01:getAvailableRegions/>")
|
||||
Map<Integer, Region> getRegionsById();
|
||||
Multimap<IdAndName, String> getRegionsById();
|
||||
|
||||
/**
|
||||
* Provides access to Zone features.
|
||||
|
|
|
@ -23,30 +23,49 @@ import static com.google.common.base.Objects.toStringHelper;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ForwardingMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* A region is a set of territory names.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalGroup {
|
||||
private final String id;
|
||||
public class DirectionalGroup extends ForwardingMultimap<String, String> {
|
||||
|
||||
private final String name;
|
||||
private final Optional<String> description;
|
||||
private final Multimap<String, String> regionToTerritories;
|
||||
|
||||
private DirectionalGroup(String id, String name) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
private DirectionalGroup(String name, Optional<String> description,
|
||||
Multimap<String, String> regionToTerritories) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
this.description = checkNotNull(description, "description of %s", name);
|
||||
this.regionToTerritories = checkNotNull(regionToTerritories, "regionToTerritories of %s", name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Optional<String> getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Multimap<String, String> getRegionToTerritories() {
|
||||
return regionToTerritories;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Multimap<String, String> delegate() {
|
||||
return regionToTerritories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name);
|
||||
return Objects.hashCode(name, regionToTerritories);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,12 +75,13 @@ public class DirectionalGroup {
|
|||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalGroup that = DirectionalGroup.class.cast(obj);
|
||||
return equal(this.id, that.id) && equal(this.name, that.name);
|
||||
return equal(this.name, that.name) && equal(this.regionToTerritories, that.regionToTerritories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper(this).omitNullValues().add("id", id).add("name", name).toString();
|
||||
return toStringHelper(this).omitNullValues().add("name", name).add("description", description.orNull())
|
||||
.add("regionToTerritories", regionToTerritories).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
|
@ -73,16 +93,10 @@ public class DirectionalGroup {
|
|||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
private Optional<String> description = Optional.absent();
|
||||
private ImmutableMultimap.Builder<String, String> regionToTerritories = ImmutableMultimap
|
||||
.<String, String> builder();
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getName()
|
||||
|
@ -92,12 +106,50 @@ public class DirectionalGroup {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = Optional.fromNullable(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds to current regionToTerritories
|
||||
*
|
||||
* @see DirectionalGroup#getRegionToTerritories()
|
||||
*/
|
||||
public Builder mapRegionToTerritories(String region, Iterable<String> territories) {
|
||||
this.regionToTerritories.putAll(region, territories);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds to current regionToTerritories
|
||||
*
|
||||
* @see DirectionalGroup#getRegionToTerritories()
|
||||
*/
|
||||
public Builder mapRegionToTerritory(String region, String territory) {
|
||||
this.regionToTerritories.put(region, territory);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces current regionToTerritories
|
||||
*
|
||||
* @see DirectionalGroup#getRegionToTerritories()
|
||||
*/
|
||||
public Builder regionToTerritories(Multimap<String, String> regionToTerritories) {
|
||||
this.regionToTerritories = ImmutableMultimap.<String, String> builder().putAll(regionToTerritories);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalGroup build() {
|
||||
return new DirectionalGroup(id, name);
|
||||
return new DirectionalGroup(name, description, regionToTerritories.build());
|
||||
}
|
||||
|
||||
public Builder from(DirectionalGroup in) {
|
||||
return id(in.id).name(in.name);
|
||||
return name(in.getName()).regionToTerritories(in.getRegionToTerritories());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ForwardingSet;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* A region is a set of territory names.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalGroupNameAndRegions extends ForwardingSet<Region> {
|
||||
|
||||
private final String name;
|
||||
private final Set<Region> regions;
|
||||
|
||||
private DirectionalGroupNameAndRegions(String name, Set<Region> regions) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.regions = checkNotNull(regions, "regions of %s", name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<Region> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Region> delegate() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, regions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalGroupNameAndRegions that = DirectionalGroupNameAndRegions.class.cast(obj);
|
||||
return equal(this.name, that.name) && equal(this.regions, that.regions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper(this).add("name", name).add("regions", regions).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String name;
|
||||
private ImmutableSet.Builder<Region> regions = ImmutableSet.<Region> builder();
|
||||
|
||||
/**
|
||||
* @see DirectionalGroupNameAndRegions#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds to current regions
|
||||
*
|
||||
* @see DirectionalGroupNameAndRegions#getRegions()
|
||||
*/
|
||||
public Builder addRegion(Region region) {
|
||||
this.regions.add(region);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces current regions
|
||||
*
|
||||
* @see DirectionalGroupNameAndRegions#getRegions()
|
||||
*/
|
||||
public Builder regions(Iterable<Region> regions) {
|
||||
this.regions = ImmutableSet.<Region> builder().addAll(regions);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalGroupNameAndRegions build() {
|
||||
return new DirectionalGroupNameAndRegions(name, regions.build());
|
||||
}
|
||||
|
||||
public Builder from(DirectionalGroupNameAndRegions in) {
|
||||
return name(in.getName()).regions(in.getRegions());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,14 +33,14 @@ public class DirectionalRecordDetail {
|
|||
private final String zoneName;
|
||||
private final String name;
|
||||
private final String id;
|
||||
private final Optional<DirectionalGroup> group;
|
||||
private final Optional<DirectionalGroup> geolocationGroup;
|
||||
private final Optional<DirectionalGroup> sourceIpGroup;
|
||||
private final Optional<IdAndName> group;
|
||||
private final Optional<IdAndName> geolocationGroup;
|
||||
private final Optional<IdAndName> sourceIpGroup;
|
||||
private final DirectionalRecord record;
|
||||
|
||||
private DirectionalRecordDetail(String zoneName, String name, String id,
|
||||
Optional<DirectionalGroup> group, Optional<DirectionalGroup> geolocationGroup,
|
||||
Optional<DirectionalGroup> sourceIpGroup, DirectionalRecord record) {
|
||||
Optional<IdAndName> group, Optional<IdAndName> geolocationGroup,
|
||||
Optional<IdAndName> sourceIpGroup, DirectionalRecord record) {
|
||||
this.zoneName = checkNotNull(zoneName, "zoneName");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.id = checkNotNull(id, "id");
|
||||
|
@ -65,21 +65,21 @@ public class DirectionalRecordDetail {
|
|||
/**
|
||||
* group containing all regions that you have not specifically configured in {@link #getGeolocationGroup()}
|
||||
*/
|
||||
public Optional<DirectionalGroup> getGroup() {
|
||||
public Optional<IdAndName> getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* group containing territories.
|
||||
*/
|
||||
public Optional<DirectionalGroup> getGeolocationGroup() {
|
||||
public Optional<IdAndName> getGeolocationGroup() {
|
||||
return geolocationGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* group containing IPV4 or IPV6 ranges.
|
||||
*/
|
||||
public Optional<DirectionalGroup> getSourceIpGroup() {
|
||||
public Optional<IdAndName> getSourceIpGroup() {
|
||||
return sourceIpGroup;
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,9 @@ public class DirectionalRecordDetail {
|
|||
private String zoneName;
|
||||
private String name;
|
||||
private String id;
|
||||
private Optional<DirectionalGroup> group = Optional.absent();
|
||||
private Optional<DirectionalGroup> geolocationGroup = Optional.absent();
|
||||
private Optional<DirectionalGroup> sourceIpGroup = Optional.absent();
|
||||
private Optional<IdAndName> group = Optional.absent();
|
||||
private Optional<IdAndName> geolocationGroup = Optional.absent();
|
||||
private Optional<IdAndName> sourceIpGroup = Optional.absent();
|
||||
private DirectionalRecord record;
|
||||
|
||||
/**
|
||||
|
@ -153,7 +153,7 @@ public class DirectionalRecordDetail {
|
|||
/**
|
||||
* @see DirectionalRecordDetail#getGroup()
|
||||
*/
|
||||
public Builder group(DirectionalGroup group) {
|
||||
public Builder group(IdAndName group) {
|
||||
this.group = Optional.fromNullable(group);
|
||||
return this;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class DirectionalRecordDetail {
|
|||
/**
|
||||
* @see DirectionalRecordDetail#getGeolocationGroup()
|
||||
*/
|
||||
public Builder geolocationGroup(DirectionalGroup geolocationGroup) {
|
||||
public Builder geolocationGroup(IdAndName geolocationGroup) {
|
||||
this.geolocationGroup = Optional.fromNullable(geolocationGroup);
|
||||
return this;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public class DirectionalRecordDetail {
|
|||
/**
|
||||
* @see DirectionalRecordDetail#getSourceIpGroup()
|
||||
*/
|
||||
public Builder sourceIpGroup(DirectionalGroup sourceIpGroup) {
|
||||
public Builder sourceIpGroup(IdAndName sourceIpGroup) {
|
||||
this.sourceIpGroup = Optional.fromNullable(sourceIpGroup);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -25,28 +25,28 @@ import com.google.common.base.Objects;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class Account {
|
||||
public static Account fromIdAndName(String id, String name) {
|
||||
return new Account(id, name);
|
||||
public final class IdAndName {
|
||||
public static IdAndName fromIdAndName(String id, String name) {
|
||||
return new IdAndName(id, name);
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
private Account(String id, String name) {
|
||||
private IdAndName(String id, String name) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name for %s", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the account. ex {@code AAAAAAAAAAAAAAAA}
|
||||
* The id of the resource. ex {@code AAAAAAAAAAAAAAAA}
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the account. ex {@code jclouds}
|
||||
* The name of the resource. ex {@code jclouds}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@ -65,7 +65,7 @@ public final class Account {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Account that = Account.class.cast(obj);
|
||||
IdAndName that = IdAndName.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id) && Objects.equal(this.name, that.name);
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ForwardingSet;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* A region is a set of territory names.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Region extends ForwardingSet<String> {
|
||||
|
||||
private final String name;
|
||||
private final Set<String> territoryNames;
|
||||
|
||||
private Region(String name, Set<String> territoryNames) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.territoryNames = checkNotNull(territoryNames, "territoryNames of %s", name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<String> getTerritoryNames() {
|
||||
return territoryNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> delegate() {
|
||||
return territoryNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, territoryNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
Region that = Region.class.cast(obj);
|
||||
return equal(this.name, that.name) && equal(this.territoryNames, that.territoryNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper(this).add("name", name).add("territoryNames", territoryNames).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String name;
|
||||
private ImmutableSet.Builder<String> territoryNames = ImmutableSet.<String> builder();
|
||||
|
||||
/**
|
||||
* @see Region#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds to current territoryNames
|
||||
*
|
||||
* @see Region#getTerritoryNames()
|
||||
*/
|
||||
public Builder addTerritoryName(String territoryName) {
|
||||
this.territoryNames.add(territoryName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces current territoryNames
|
||||
*
|
||||
* @see Region#getTerritoryNames()
|
||||
*/
|
||||
public Builder territoryNames(Iterable<String> territoryNames) {
|
||||
this.territoryNames = ImmutableSet.<String> builder().addAll(territoryNames);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Region build() {
|
||||
return new Region(name, territoryNames.build());
|
||||
}
|
||||
|
||||
public Builder from(Region in) {
|
||||
return name(in.getName()).territoryNames(in.getTerritoryNames());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,6 @@ import org.jclouds.ultradns.ws.binders.DirectionalGroupCoordinatesToXML;
|
|||
import org.jclouds.ultradns.ws.domain.AccountLevelGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupCoordinates;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupNameAndRegions;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.AccountLevelGroupsHandler;
|
||||
|
@ -68,7 +67,7 @@ public interface DirectionalGroupApi {
|
|||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Payload("<v01:getDirectionalDNSGroupDetails><GroupId>{GroupId}</GroupId></v01:getDirectionalDNSGroupDetails>")
|
||||
@Nullable
|
||||
DirectionalGroupNameAndRegions get(@PayloadParam("GroupId") String groupId);
|
||||
DirectionalGroup get(@PayloadParam("GroupId") String groupId);
|
||||
|
||||
/**
|
||||
* Returns all account-level groups.
|
||||
|
|
|
@ -82,7 +82,7 @@ public interface RoundRobinPoolApi {
|
|||
* @param hostname
|
||||
* {@link RoundRobinPool#getDName() dname} of the RR pool {ex.
|
||||
* www.jclouds.org.}
|
||||
* @return the {@code guid} of the new record
|
||||
* @return the {@code guid} of the new pool
|
||||
* @throws ResourceAlreadyExistsException
|
||||
* if a pool already exists with the same attrs
|
||||
*/
|
||||
|
|
|
@ -24,19 +24,19 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AccountHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Account> {
|
||||
public class AccountHandler extends ParseSax.HandlerForGeneratedRequestWithResult<IdAndName> {
|
||||
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
public Account getResult() {
|
||||
public IdAndName getResult() {
|
||||
try {
|
||||
return account;
|
||||
} finally {
|
||||
|
@ -48,7 +48,7 @@ public class AccountHandler extends ParseSax.HandlerForGeneratedRequestWithResul
|
|||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (equalsOrSuffix(qName, "AccountDetailsData")) {
|
||||
account = Account.fromIdAndName(attributes.get("accountID"), attributes.get("accountName"));
|
||||
account = IdAndName.fromIdAndName(attributes.get("accountID"), attributes.get("accountName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,8 @@ package org.jclouds.ultradns.ws.xml;
|
|||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupNameAndRegions;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupNameAndRegions.Builder;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup.Builder;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
@ -32,12 +31,12 @@ import com.google.common.base.Splitter;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalGroupNameAndRegionsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<DirectionalGroupNameAndRegions> {
|
||||
public class DirectionalGroupNameAndRegionsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<DirectionalGroup> {
|
||||
|
||||
private final Builder group = DirectionalGroupNameAndRegions.builder();
|
||||
private final Builder group = DirectionalGroup.builder();
|
||||
|
||||
@Override
|
||||
public DirectionalGroupNameAndRegions getResult() {
|
||||
public DirectionalGroup getResult() {
|
||||
return group.build();
|
||||
}
|
||||
|
||||
|
@ -46,11 +45,9 @@ public class DirectionalGroupNameAndRegionsHandler extends ParseSax.HandlerForGe
|
|||
if (equalsOrSuffix(qName, "DirectionalDNSGroupDetail")) {
|
||||
group.name(attrs.getValue("GroupName"));
|
||||
} else if (equalsOrSuffix(qName, "RegionForNewGroups")) {
|
||||
String regionName = attrs.getValue("RegionName");
|
||||
Iterable<String> territories = Splitter.on(';').split(attrs.getValue("TerritoryName"));
|
||||
Region region = Region.builder()
|
||||
.name(attrs.getValue("RegionName"))
|
||||
.territoryNames(territories).build();
|
||||
group.addRegion(region);
|
||||
group.mapRegionToTerritories(regionName, territories);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import static org.jclouds.ultradns.ws.domain.IdAndName.*;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -64,19 +64,14 @@ public class DirectionalRecordDetailHandler extends
|
|||
drd.id(attributes.get("DirPoolRecordId"));
|
||||
}
|
||||
if (attributes.containsKey("GroupId")) {
|
||||
drd.group(DirectionalGroup.builder()
|
||||
.id(attributes.get("GroupId"))
|
||||
.name(attributes.get("GroupName")).build());
|
||||
drd.group(fromIdAndName(attributes.get("GroupId"), attributes.get("GroupName")));
|
||||
}
|
||||
if (attributes.containsKey("GeolocationGroupId")) {
|
||||
drd.geolocationGroup(DirectionalGroup.builder()
|
||||
.id(attributes.get("GeolocationGroupId"))
|
||||
.name(attributes.get("GeolocationGroupName")).build());
|
||||
drd.geolocationGroup(fromIdAndName(attributes.get("GeolocationGroupId"),
|
||||
attributes.get("GeolocationGroupName")));
|
||||
}
|
||||
if (attributes.containsKey("SourceIPGroupId")) {
|
||||
drd.sourceIpGroup(DirectionalGroup.builder()
|
||||
.id(attributes.get("SourceIPGroupId"))
|
||||
.name(attributes.get("SourceIPGroupName")).build());
|
||||
drd.sourceIpGroup(fromIdAndName(attributes.get("SourceIPGroupId"), attributes.get("SourceIPGroupName")));
|
||||
}
|
||||
if (attributes.containsKey("recordType")) {
|
||||
dr.type(attributes.get("recordType"));
|
||||
|
|
|
@ -24,23 +24,24 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class RegionListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Map<Integer, Region>> {
|
||||
public class RegionListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Multimap<IdAndName, String>> {
|
||||
|
||||
private final Builder<Integer, Region> regions = ImmutableMap.<Integer, Region> builder();
|
||||
private final Builder<IdAndName, String> regions = ImmutableMultimap.<IdAndName, String> builder();
|
||||
|
||||
@Override
|
||||
public Map<Integer, Region> getResult() {
|
||||
public Multimap<IdAndName, String> getResult() {
|
||||
return regions.build();
|
||||
}
|
||||
|
||||
|
@ -48,12 +49,8 @@ public class RegionListHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
public void startElement(String url, String name, String qName, Attributes attrs) {
|
||||
if (equalsOrSuffix(qName, "Region")) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
int id = Integer.parseInt(attributes.get("RegionID"));
|
||||
Iterable<String> territories = Splitter.on(';').split(attributes.get("TerritoryName"));
|
||||
Region region = Region.builder()
|
||||
.name(attributes.get("RegionName"))
|
||||
.territoryNames(territories).build();
|
||||
regions.put(id, region);
|
||||
IdAndName region = IdAndName.fromIdAndName(attributes.get("RegionID"), attributes.get("RegionName"));
|
||||
regions.putAll(region, Splitter.on(';').split(attributes.get("TerritoryName")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,11 @@ package org.jclouds.ultradns.ws;
|
|||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -37,26 +36,26 @@ public class UltraDNSWSApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
|
||||
@Test
|
||||
protected void testGetCurrentAccount() {
|
||||
Account account = api.getCurrentAccount();
|
||||
IdAndName account = api.getCurrentAccount();
|
||||
checkAccount(account);
|
||||
}
|
||||
|
||||
private void checkAccount(Account account) {
|
||||
private void checkAccount(IdAndName account) {
|
||||
assertNotNull(account.getId(), "Id cannot be null for " + account);
|
||||
assertNotNull(account.getName(), "Name cannot be null for " + account);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRegions() {
|
||||
for (Entry<Integer, Region> region : api.getRegionsById().entrySet()) {
|
||||
for (Entry<IdAndName, Collection<String>> region : api.getRegionsById().asMap().entrySet()) {
|
||||
checkRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRegion(Entry<Integer, Region> region) {
|
||||
assertTrue(region.getKey() > 0, "Id cannot be negative " + region);
|
||||
assertNotNull(region.getValue().getName(), "Name cannot be null " + region);
|
||||
assertNotNull(region.getValue().getTerritoryNames(), "TerritoryNames cannot be null " + region);
|
||||
assertFalse(region.getValue().getTerritoryNames().isEmpty(), "TerritoryNames cannot be empty " + region);
|
||||
private void checkRegion(Entry<IdAndName, Collection<String>> region) {
|
||||
assertNotNull(region.getKey().getId(), "Id cannot be null " + region);
|
||||
assertNotNull(region.getKey().getName(), "Name cannot be null " + region);
|
||||
assertNotNull(region.getValue(), "TerritoryNames cannot be null " + region);
|
||||
assertFalse(region.getValue().isEmpty(), "TerritoryNames cannot be empty " + region);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ import java.util.EnumSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.AccountLevelGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupCoordinates;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupNameAndRegions;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordType;
|
||||
|
@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
|
|||
@Test(groups = "live", singleThreaded = true, testName = "DirectionalGroupApiLiveTest")
|
||||
public class DirectionalGroupApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
@ -81,7 +81,7 @@ public class DirectionalGroupApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
@Test
|
||||
public void testGetDirectionalGroup() {
|
||||
for (AccountLevelGroup group : api().listAccountLevelGroups()) {
|
||||
DirectionalGroupNameAndRegions withRegions = api().get(group.getId());
|
||||
DirectionalGroup withRegions = api().get(group.getId());
|
||||
assertEquals(withRegions.getName(), group.getName());
|
||||
assertTrue(withRegions.size() > 0);
|
||||
}
|
||||
|
|
|
@ -27,12 +27,11 @@ import java.util.EnumSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordType;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
@ -49,7 +48,7 @@ import com.google.common.collect.Sets;
|
|||
@Test(groups = "live", singleThreaded = true, testName = "DirectionalPoolApiLiveTest")
|
||||
public class DirectionalPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
@ -76,7 +75,7 @@ public class DirectionalPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
assertNotNull(pool.getTieBreak(), "TieBreak cannot be null " + pool);
|
||||
}
|
||||
|
||||
Set<DirectionalGroup> allDirectionalGroups = Sets.newLinkedHashSet();
|
||||
Set<IdAndName> allDirectionalGroups = Sets.newLinkedHashSet();
|
||||
|
||||
@Test
|
||||
public void testListDirectionalRecords() {
|
||||
|
@ -86,10 +85,10 @@ public class DirectionalPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
for (DirectionalRecordDetail rr : api(zone.getName())
|
||||
.listRecordsByNameAndType(pool.getName(), type.getCode())) {
|
||||
checkDirectionalRecordDetail(rr);
|
||||
Iterable<DirectionalGroup> groups = Optional.presentInstances(ImmutableSet.of(rr.getGroup(),
|
||||
Iterable<IdAndName> groups = Optional.presentInstances(ImmutableSet.of(rr.getGroup(),
|
||||
rr.getGeolocationGroup(), rr.getGeolocationGroup()));
|
||||
assertFalse(Iterables.isEmpty(groups), "No groups " + rr);
|
||||
for (DirectionalGroup group : groups) {
|
||||
for (IdAndName group : groups) {
|
||||
allDirectionalGroups.add(group);
|
||||
assertNotNull(group.getId(), "Id cannot be null " + group);
|
||||
assertNotNull(group.getName(), "Name cannot be null " + group);
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
|
@ -53,7 +53,7 @@ import com.google.common.collect.FluentIterable;
|
|||
public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private String zoneName = System.getProperty("user.name").replace('.', '-') + ".rr.ultradnstest.jclouds.org.";
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
|
|
@ -29,7 +29,7 @@ import static org.testng.Assert.fail;
|
|||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
|
||||
import org.jclouds.ultradns.ws.domain.RoundRobinPool;
|
||||
|
@ -50,7 +50,7 @@ import com.google.common.collect.FluentIterable;
|
|||
public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private String zoneName = System.getProperty("user.name").replace('.', '-') + ".rrpool.ultradnstest.jclouds.org.";
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
|
|
@ -30,7 +30,7 @@ import static org.testng.Assert.fail;
|
|||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecordSpec;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
|
@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private String zoneName = System.getProperty("user.name").replace('.', '-') + ".tcpool.ultradnstest.jclouds.org.";
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
|
|
@ -29,7 +29,7 @@ import static org.testng.Assert.fail;
|
|||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.domain.Zone.Type;
|
||||
import org.jclouds.ultradns.ws.domain.ZoneProperties;
|
||||
|
@ -45,7 +45,7 @@ import com.google.common.collect.FluentIterable;
|
|||
@Test(groups = "live", testName = "ZoneApiLiveTest")
|
||||
public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
private IdAndName account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.xml.AccountHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -36,16 +36,16 @@ public class GetAccountsListOfUserResponseTest extends BaseHandlerTest {
|
|||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/account.xml");
|
||||
|
||||
Account expected = expected();
|
||||
IdAndName expected = expected();
|
||||
|
||||
AccountHandler handler = injector.getInstance(AccountHandler.class);
|
||||
Account result = factory.create(handler).parse(is);
|
||||
IdAndName result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
|
||||
public Account expected() {
|
||||
return Account.fromIdAndName("AAAAAAAAAAAAAAAA", "jclouds");
|
||||
public IdAndName expected() {
|
||||
return IdAndName.fromIdAndName("AAAAAAAAAAAAAAAA", "jclouds");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,18 +18,19 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.parse;
|
||||
|
||||
import static org.jclouds.ultradns.ws.domain.IdAndName.fromIdAndName;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.IdAndName;
|
||||
import org.jclouds.ultradns.ws.xml.RegionListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -40,25 +41,21 @@ public class GetAvailableRegionsResponseTest extends BaseHandlerTest {
|
|||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/regions.xml");
|
||||
|
||||
Map<Integer, Region> expected = expected();
|
||||
Multimap<IdAndName, String> expected = expected();
|
||||
|
||||
RegionListHandler handler = injector.getInstance(RegionListHandler.class);
|
||||
Map<Integer, Region> result = factory.create(handler).parse(is);
|
||||
Multimap<IdAndName, String> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public Map<Integer, Region> expected() {
|
||||
return ImmutableMap.<Integer, Region> builder()
|
||||
.put(14, Region.builder()
|
||||
.name("Anonymous Proxy (A1)")
|
||||
.addTerritoryName("Anonymous Proxy").build())
|
||||
.put(3, Region.builder()
|
||||
.name("Antarctica")
|
||||
.territoryNames(ImmutableSet.<String> builder()
|
||||
public Multimap<IdAndName, String> expected() {
|
||||
return ImmutableMultimap.<IdAndName, String> builder()
|
||||
.put(fromIdAndName("14", "Anonymous Proxy (A1)"), "Anonymous Proxy")
|
||||
.putAll(fromIdAndName("3", "Antarctica"), ImmutableSet.<String> builder()
|
||||
.add("Antarctica")
|
||||
.add("Bouvet Island")
|
||||
.add("French Southern Territories").build())
|
||||
.add("French Southern Territories")
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -23,11 +23,12 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroupNameAndRegions;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalGroupNameAndRegionsHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -37,27 +38,22 @@ public class GetDirectionalDNSGroupDetailsResponseTest extends BaseHandlerTest {
|
|||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/directionalgroup.xml");
|
||||
|
||||
DirectionalGroupNameAndRegions expected = expected();
|
||||
DirectionalGroup expected = expected();
|
||||
|
||||
DirectionalGroupNameAndRegionsHandler handler = injector.getInstance(DirectionalGroupNameAndRegionsHandler.class);
|
||||
DirectionalGroupNameAndRegions result = factory.create(handler).parse(is);
|
||||
DirectionalGroup result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public DirectionalGroupNameAndRegions expected() {
|
||||
return DirectionalGroupNameAndRegions.builder()
|
||||
public DirectionalGroup expected() {
|
||||
return DirectionalGroup.builder()
|
||||
.name("NON-EU")
|
||||
.addRegion(Region.builder()
|
||||
.name("Anonymous Proxy (A1)")
|
||||
.addTerritoryName("Anonymous Proxy").build())
|
||||
.addRegion(Region.builder()
|
||||
.name("Mexico")
|
||||
.addTerritoryName("Mexico").build())
|
||||
.addRegion(Region.builder()
|
||||
.name("Antarctica")
|
||||
.addTerritoryName("Bouvet Island")
|
||||
.addTerritoryName("French Southern Territories")
|
||||
.addTerritoryName("Antarctica").build()).build();
|
||||
.mapRegionToTerritory("Anonymous Proxy (A1)", "Anonymous Proxy")
|
||||
.mapRegionToTerritory("Mexico", "Mexico")
|
||||
.mapRegionToTerritories("Antarctica", ImmutableList.<String> builder()
|
||||
.add("Bouvet Island")
|
||||
.add("French Southern Territories")
|
||||
.add("Antarctica").build()).build();
|
||||
}
|
||||
}
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.parse;
|
||||
|
||||
import static org.jclouds.ultradns.ws.domain.IdAndName.fromIdAndName;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalRecordDetailListHandler;
|
||||
|
@ -55,10 +55,7 @@ public class GetDirectionalDNSRecordsForHostResponseTest extends BaseHandlerTest
|
|||
.zoneName("geo.jclouds.org.")
|
||||
.name("www.geo.jclouds.org.")
|
||||
.id("A000000000000001")
|
||||
.geolocationGroup(DirectionalGroup.builder()
|
||||
.id("C000000000000001")
|
||||
.name("southamerica")
|
||||
.build())
|
||||
.geolocationGroup(fromIdAndName("C000000000000001", "southamerica"))
|
||||
.record(DirectionalRecord.drBuilder()
|
||||
.type("CNAME")
|
||||
.ttl(300)
|
||||
|
@ -68,10 +65,7 @@ public class GetDirectionalDNSRecordsForHostResponseTest extends BaseHandlerTest
|
|||
.zoneName("geo.jclouds.org.")
|
||||
.name("www.geo.jclouds.org.")
|
||||
.id("A000000000000002")
|
||||
.group(DirectionalGroup.builder()
|
||||
.id("B000000000000001")
|
||||
.name("All Non-Configured Regions")
|
||||
.build())
|
||||
.group(fromIdAndName("B000000000000001", "All Non-Configured Regions"))
|
||||
.record(DirectionalRecord.drBuilder()
|
||||
.type("A")
|
||||
.ttl(500)
|
||||
|
@ -81,10 +75,7 @@ public class GetDirectionalDNSRecordsForHostResponseTest extends BaseHandlerTest
|
|||
.zoneName("geo.jclouds.org.")
|
||||
.name("www.geo.jclouds.org.")
|
||||
.id("A000000000000003")
|
||||
.geolocationGroup(DirectionalGroup.builder()
|
||||
.id("C000000000000002")
|
||||
.name("antarctica-unsupported")
|
||||
.build())
|
||||
.geolocationGroup(fromIdAndName("C000000000000002", "antarctica-unsupported"))
|
||||
.record(DirectionalRecord.drBuilder()
|
||||
.type("A")
|
||||
.ttl(0)
|
||||
|
@ -94,10 +85,7 @@ public class GetDirectionalDNSRecordsForHostResponseTest extends BaseHandlerTest
|
|||
.zoneName("geo.jclouds.org.")
|
||||
.name("www.geo.jclouds.org.")
|
||||
.id("A000000000000004")
|
||||
.geolocationGroup(DirectionalGroup.builder()
|
||||
.id("C000000000000003")
|
||||
.name("alazona")
|
||||
.build())
|
||||
.geolocationGroup(fromIdAndName("C000000000000003", "alazona"))
|
||||
.record(DirectionalRecord.drBuilder()
|
||||
.type("A")
|
||||
.ttl(86400) // default
|
||||
|
|
Loading…
Reference in New Issue