mirror of https://github.com/apache/jclouds.git
Merge pull request #194 from jsonking/695-1
Added Templates+client classes and calls+tests, plus some refactoring
This commit is contained in:
commit
81cbe7c0b1
|
@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud;
|
|||
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TemplateAsyncClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
|
||||
|
||||
/**
|
||||
|
@ -45,4 +46,10 @@ public interface TerremarkEnterpriseCloudAsyncClient {
|
|||
*/
|
||||
@Delegate
|
||||
VirtualMachineAsyncClient getVirtualMachineClient();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Template features.
|
||||
*/
|
||||
@Delegate
|
||||
TemplateAsyncClient getTemplateClient();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TaskClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TemplateClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient;
|
||||
|
||||
/**
|
||||
|
@ -49,4 +50,10 @@ public interface TerremarkEnterpriseCloudClient {
|
|||
*/
|
||||
@Delegate
|
||||
VirtualMachineClient getVirtualMachineClient();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Template features.
|
||||
*/
|
||||
@Delegate
|
||||
TemplateClient getTemplateClient();
|
||||
}
|
||||
|
|
|
@ -31,10 +31,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudAsyncClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TaskClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.handlers.TerremarkEnterpriseCloudErrorHandler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -52,6 +49,7 @@ public class TerremarkEnterpriseCloudRestClientModule extends
|
|||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||
.put(TaskClient.class, TaskAsyncClient.class)
|
||||
.put(VirtualMachineClient.class, VirtualMachineAsyncClient.class)
|
||||
.put(TemplateClient.class, TemplateAsyncClient.class)
|
||||
.build();
|
||||
|
||||
public TerremarkEnterpriseCloudRestClientModule() {
|
||||
|
|
|
@ -119,8 +119,8 @@ public class Action extends BaseNamedResource<Action> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Action> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder fromBaseResource(BaseResource<Action> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,14 +171,15 @@ public class Action extends BaseNamedResource<Action> {
|
|||
@XmlAttribute
|
||||
protected ActionDisabled actionDisabled;
|
||||
|
||||
public Action(URI href, String type, String name, @Nullable ActionDisabled actionDisabled) {
|
||||
private Action(URI href, String type, String name, @Nullable ActionDisabled actionDisabled) {
|
||||
super(href, type, name);
|
||||
this.actionDisabled = actionDisabled;
|
||||
}
|
||||
|
||||
protected Action() {
|
||||
private Action() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* The attribute actionDisabled appears only when the example has an action
|
||||
* disabled for business rules.
|
||||
|
|
|
@ -1,31 +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.tmrk.enterprisecloud.domain;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
|
||||
/**
|
||||
* @author Jason King
|
||||
*/
|
||||
public class Group extends BaseNamedResource<Group> {
|
||||
|
||||
public Group() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -34,12 +34,12 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
*/
|
||||
public class Layout {
|
||||
@XmlElement(name = "Group")
|
||||
private Group group;
|
||||
private NamedResource group;
|
||||
|
||||
@XmlElement(name = "Row")
|
||||
private Row row;
|
||||
private NamedResource row;
|
||||
|
||||
public Layout(@Nullable Group group, @Nullable Row row) {
|
||||
public Layout(@Nullable NamedResource group, @Nullable NamedResource row) {
|
||||
this.group = group;
|
||||
this.row = row;
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ public class Layout {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Group getGroup() {
|
||||
public NamedResource getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public Row getRow() {
|
||||
public NamedResource getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
|
@ -26,6 +27,7 @@ import javax.xml.bind.annotation.XmlEnum;
|
|||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
|
@ -134,8 +136,8 @@ public class Link extends BaseNamedResource<Link> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Link> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder fromBaseResource(BaseResource<Link> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,12 +187,12 @@ public class Link extends BaseNamedResource<Link> {
|
|||
@XmlAttribute
|
||||
protected Relationship rel;
|
||||
|
||||
public Link(URI href, String type, String name, Relationship rel) {
|
||||
private Link(URI href, String type, String name, Relationship rel) {
|
||||
super(href, type, name);
|
||||
this.rel = checkNotNull(rel, "rel");
|
||||
}
|
||||
|
||||
protected Link() {
|
||||
private Link() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud.domain;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
@ -58,8 +59,8 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<NamedResource> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder fromBaseResource(BaseResource<NamedResource> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +105,7 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
|
||||
}
|
||||
|
||||
public NamedResource(URI href, String type, String name) {
|
||||
private NamedResource(URI href, String type, String name) {
|
||||
super(href, type, name);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +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.tmrk.enterprisecloud.domain;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
|
||||
/**
|
||||
* @author Jason King
|
||||
*/
|
||||
public class Row extends BaseNamedResource<Row> {
|
||||
public Row() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -18,21 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="Task">
|
||||
|
@ -40,7 +41,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
*
|
||||
*/
|
||||
@XmlRootElement(name = "Task")
|
||||
public class Task extends BaseResource<Task> {
|
||||
public class Task extends Resource<Task> {
|
||||
@XmlEnum
|
||||
public static enum Status {
|
||||
/**
|
||||
|
@ -109,7 +110,7 @@ public class Task extends BaseResource<Task> {
|
|||
return new Builder().fromTask(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<Task> {
|
||||
public static class Builder extends Resource.Builder<Task> {
|
||||
//TODO There are additional fields
|
||||
protected String operation;
|
||||
protected Status status;
|
||||
|
@ -186,8 +187,8 @@ public class Task extends BaseResource<Task> {
|
|||
|
||||
@Override
|
||||
public Task build() {
|
||||
return new Task(href, type, operation, status, impactedItem, startTime, completedTime, notes, errorMessage,
|
||||
initiatedBy);
|
||||
return new Task(href, type, name, links,
|
||||
actions, operation, status, impactedItem, startTime, completedTime, notes, errorMessage, initiatedBy);
|
||||
}
|
||||
|
||||
public Builder fromTask(Task in) {
|
||||
|
@ -200,7 +201,15 @@ public class Task extends BaseResource<Task> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Task> in) {
|
||||
public Builder fromBaseResource(BaseResource<Task> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<Task> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
|
@ -220,6 +229,30 @@ public class Task extends BaseResource<Task> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -254,9 +287,9 @@ public class Task extends BaseResource<Task> {
|
|||
@XmlElement(name = "InitiatedBy", required = true)
|
||||
protected NamedResource initiatedBy;
|
||||
|
||||
public Task(URI href, String type, String operation, Status status, NamedResource impactedItem, Date startTime,
|
||||
private Task(URI href, String type, String name, Set<Link> links, Set<Action> actions, String operation, Status status, NamedResource impactedItem, Date startTime,
|
||||
@Nullable Date completedTime, @Nullable String notes, @Nullable String errorMessage, NamedResource initiatedBy) {
|
||||
super(href, type);
|
||||
super(href, type, name, links, actions);
|
||||
this.operation = checkNotNull(operation, "operation");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.impactedItem = checkNotNull(impactedItem, "impactedItem");
|
||||
|
@ -267,7 +300,7 @@ public class Task extends BaseResource<Task> {
|
|||
this.initiatedBy = checkNotNull(initiatedBy, "initiatedBy");
|
||||
}
|
||||
|
||||
protected Task() {
|
||||
private Task() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.network.Nics;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.network.VirtualNic;
|
||||
|
@ -42,7 +43,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* @author Jason King
|
||||
*/
|
||||
@XmlRootElement(name = "HardwareConfiguration")
|
||||
public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
||||
public class HardwareConfiguration extends Resource<HardwareConfiguration> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
|
@ -57,23 +58,13 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
return new Builder().fromHardwareConfiguration(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<HardwareConfiguration> {
|
||||
public static class Builder extends Resource.Builder<HardwareConfiguration> {
|
||||
|
||||
// TODO Links
|
||||
private Set<Action> actions = Sets.newLinkedHashSet();
|
||||
private int processorCount;
|
||||
private ResourceCapacity memory;
|
||||
private Set<VirtualDisk> virtualDisks = Sets.newLinkedHashSet();
|
||||
private Set<VirtualNic> virtualNics = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see HardwareConfiguration#getActions
|
||||
*/
|
||||
public Builder actions(Set<Action> actions) {
|
||||
this.actions = ImmutableSet.<Action> copyOf(checkNotNull(actions, "actions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HardwareConfiguration#getProcessorCount
|
||||
*/
|
||||
|
@ -109,14 +100,22 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
|
||||
@Override
|
||||
public HardwareConfiguration build() {
|
||||
return new HardwareConfiguration(actions, processorCount, memory, virtualDisks, virtualNics);
|
||||
return new HardwareConfiguration(processorCount, memory, virtualDisks, virtualNics);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<HardwareConfiguration> in) {
|
||||
public Builder fromBaseResource(BaseResource<HardwareConfiguration> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<HardwareConfiguration> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
|
@ -136,6 +135,30 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -145,17 +168,13 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
}
|
||||
|
||||
public Builder fromHardwareConfiguration(HardwareConfiguration in) {
|
||||
return fromResource(in).actions(in.getActions())
|
||||
.processorCount(in.getProcessorCount())
|
||||
return fromResource(in).processorCount(in.getProcessorCount())
|
||||
.memory(in.getMemory())
|
||||
.disks(in.getVirtualDisks())
|
||||
.nics(in.getVirtualNics());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Actions", required = false)
|
||||
private Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlElement(name = "ProcessorCount", required = true)
|
||||
private int processorCount;
|
||||
|
||||
|
@ -168,22 +187,17 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
@XmlElement(name = "Nics", required = false)
|
||||
private Nics virtualNics = Nics.builder().build();
|
||||
|
||||
public HardwareConfiguration(Set<Action> actions, int processorCount, @Nullable ResourceCapacity memory, Set<VirtualDisk> virtualDisks, Set<VirtualNic> virtualNics) {
|
||||
this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build();
|
||||
private HardwareConfiguration(int processorCount, @Nullable ResourceCapacity memory, Set<VirtualDisk> virtualDisks, Set<VirtualNic> virtualNics) {
|
||||
this.virtualDisks = Disks.builder().disks(checkNotNull(virtualDisks,"virtualDisks")).build();
|
||||
this.virtualNics = Nics.builder().nics(checkNotNull(virtualNics, "virtualNics")).build();
|
||||
this.processorCount = processorCount;
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
protected HardwareConfiguration() {
|
||||
private HardwareConfiguration() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Set<Action> getActions() {
|
||||
return Collections.unmodifiableSet(actions.getActions());
|
||||
}
|
||||
|
||||
public int getProcessorCount() {
|
||||
return processorCount;
|
||||
}
|
||||
|
@ -209,7 +223,6 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
HardwareConfiguration that = (HardwareConfiguration) o;
|
||||
|
||||
if (processorCount != that.processorCount) return false;
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (!virtualDisks.equals(that.virtualDisks)) return false;
|
||||
if (memory != null ? !memory.equals(that.memory) : that.memory != null)
|
||||
return false;
|
||||
|
@ -221,7 +234,6 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + processorCount;
|
||||
result = 31 * result + (memory != null ? memory.hashCode() : 0);
|
||||
result = 31 * result + virtualDisks.hashCode();
|
||||
|
@ -231,7 +243,7 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", actions="+actions+", processorCount="+processorCount+
|
||||
return super.string()+", processorCount="+processorCount+
|
||||
", memory="+memory+", disks="+ virtualDisks +", nics="+ virtualNics;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Location of a Rest resource
|
||||
*
|
||||
|
@ -62,12 +61,12 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> fromResource(BaseResource<T> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder<T> fromBaseResource(BaseResource<T> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
public Builder<T> fromNamedResource(BaseNamedResource<T> in) {
|
||||
return fromResource(in).name(in.getName());
|
||||
return fromBaseResource(in).name(in.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +81,7 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
@XmlAttribute
|
||||
protected String name;
|
||||
|
||||
public BaseNamedResource(URI href, String type, String name) {
|
||||
protected BaseNamedResource(URI href, String type, String name) {
|
||||
super(href, type);
|
||||
this.name = checkNotNull(name, "name");
|
||||
}
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Location of a Rest resource
|
||||
*
|
||||
|
@ -38,7 +37,7 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
}
|
||||
|
||||
public Builder<T> toBuilder() {
|
||||
return new Builder<T>().fromResource(this);
|
||||
return new Builder<T>().fromBaseResource(this);
|
||||
}
|
||||
|
||||
public static class Builder<T extends BaseResource<T>> {
|
||||
|
@ -66,11 +65,11 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
return new BaseResource<T>(href, type);
|
||||
}
|
||||
|
||||
public Builder<T> fromResource(BaseResource<T> in) {
|
||||
protected Builder<T> fromBaseResource(BaseResource<T> in) {
|
||||
return type(in.getType()).href(in.getHref());
|
||||
}
|
||||
|
||||
public Builder<T> fromAttributes(Map<String, String> attributes) {
|
||||
protected Builder<T> fromAttributes(Map<String, String> attributes) {
|
||||
return href(URI.create(attributes.get("href"))).type(attributes.get("type"));
|
||||
}
|
||||
|
||||
|
@ -82,7 +81,7 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
@XmlAttribute
|
||||
protected URI href;
|
||||
|
||||
public BaseResource(URI href, String type) {
|
||||
protected BaseResource(URI href, String type) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.href = checkNotNull(href, "href");
|
||||
}
|
||||
|
@ -108,34 +107,25 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BaseResource that = (BaseResource) o;
|
||||
|
||||
if (href != null ? !href.equals(that.href) : that.href != null)
|
||||
return false;
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BaseResource<?> other = (BaseResource<?>) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
return true;
|
||||
public int hashCode() {
|
||||
int result = type != null ? type.hashCode() : 0;
|
||||
result = 31 * result + (href != null ? href.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Base Resource class.
|
||||
* has Links and Actions and name (plus href and type are inherited)
|
||||
* <xs:complexType name="Resource">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class Resource<T extends Resource<T>> extends BaseResource<T> {
|
||||
|
||||
public static <T extends Resource<T>> Builder<T> builder() {
|
||||
return new Builder<T>();
|
||||
}
|
||||
|
||||
public Builder<T> toBuilder() {
|
||||
return new Builder<T>().fromResource(this);
|
||||
}
|
||||
|
||||
public static class Builder<T extends Resource<T>> extends BaseResource.Builder<T> {
|
||||
|
||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||
protected Set<Action> actions = Sets.newLinkedHashSet();
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* @see Resource#getLinks
|
||||
*/
|
||||
public Builder<T> links(Set<Link> links) {
|
||||
this.links = ImmutableSet.<Link> copyOf(checkNotNull(links, "links"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Resource#getActions
|
||||
*/
|
||||
public Builder<T> actions(Set<Action> actions) {
|
||||
this.actions = ImmutableSet.<Action> copyOf(checkNotNull(actions, "actions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Resource#getActions
|
||||
*/
|
||||
public Builder<T> name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return this;
|
||||
}
|
||||
|
||||
public Resource<T> build() {
|
||||
return new Resource<T>(href, type, name, links, actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Builder<T> fromBaseResource(BaseResource<T> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
public Builder<T> fromResource(Resource<T> in) {
|
||||
return fromBaseResource(in).links(in.getLinks())
|
||||
.actions(in.getActions()).name(in.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Builder<T> fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = false)
|
||||
protected Links links = Links.builder().build();
|
||||
|
||||
@XmlElement(name = "Actions", required = false)
|
||||
protected Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlAttribute(required = false)
|
||||
protected String name;
|
||||
|
||||
protected Resource(URI href, String type, @Nullable String name, Set<Link> links, Set<Action> actions) {
|
||||
super(href, type);
|
||||
this.name = name;
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build();
|
||||
}
|
||||
|
||||
protected Resource() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(links.getLinks());
|
||||
}
|
||||
|
||||
public Set<Action> getActions() {
|
||||
return Collections.unmodifiableSet(actions.getActions());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Resource resource = (Resource) o;
|
||||
|
||||
if (actions != null ? !actions.equals(resource.actions) : resource.actions != null)
|
||||
return false;
|
||||
if (links != null ? !links.equals(resource.links) : resource.links != null)
|
||||
return false;
|
||||
if (name != null ? !name.equals(resource.name) : resource.name != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||
result = 31 * result + (actions != null ? actions.hashCode() : 0);
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", name="+name+", links="+links+", actions="+actions;
|
||||
}
|
||||
}
|
|
@ -18,8 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -32,19 +34,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* @author Jason King
|
||||
*/
|
||||
@XmlRootElement(name="AssignedIpAddresses")
|
||||
public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
||||
|
||||
//TODO links
|
||||
|
||||
@XmlElement(name = "Actions", required = true)
|
||||
private Actions actions = Actions.builder().build();
|
||||
public class AssignedIpAddresses extends Resource<AssignedIpAddresses> {
|
||||
|
||||
@XmlElement(name = "Networks", required = true)
|
||||
private DeviceNetworks networks = new DeviceNetworks();
|
||||
|
||||
public AssignedIpAddresses(URI href, String type, Actions actions, DeviceNetworks networks) {
|
||||
super(href, type);
|
||||
checkNotNull(actions,"actions");
|
||||
public AssignedIpAddresses(URI href, String type, String name, Actions actions, DeviceNetworks networks) {
|
||||
super(href, type, name, Sets.<Link>newIdentityHashSet(), actions.getActions());
|
||||
checkNotNull(networks,"networks");
|
||||
}
|
||||
|
||||
|
@ -52,10 +48,6 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Actions getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public DeviceNetworks getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
@ -68,7 +60,6 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
|
||||
AssignedIpAddresses that = (AssignedIpAddresses) o;
|
||||
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (!networks.equals(that.networks)) return false;
|
||||
|
||||
return true;
|
||||
|
@ -77,14 +68,13 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + networks.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", actions="+actions+", networks="+networks;
|
||||
return super.string()+", networks="+networks;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
|
@ -27,12 +27,14 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
* <xs:complexType name="DeviceNetwork">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class DeviceNetwork extends BaseNamedResource<DeviceNetwork> {
|
||||
public class DeviceNetwork extends Resource<DeviceNetwork> {
|
||||
|
||||
//TODO: Builder
|
||||
|
||||
@XmlElement(name = "IpAddresses")
|
||||
private DeviceIps ipAddresses = new DeviceIps();
|
||||
|
||||
protected DeviceNetwork() {
|
||||
private DeviceNetwork() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
|
@ -26,6 +28,8 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
@ -93,8 +97,8 @@ public class NetworkReference extends BaseNamedResource<NetworkReference> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<NetworkReference> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder fromBaseResource(BaseResource<NetworkReference> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,17 +132,25 @@ public class NetworkReference extends BaseNamedResource<NetworkReference> {
|
|||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "NetworkType")
|
||||
private NetworkType networkType;
|
||||
|
||||
public NetworkReference(URI href, String type, String name,@Nullable NetworkType networkType) {
|
||||
private NetworkReference(URI href, String type, String name,@Nullable NetworkType networkType) {
|
||||
super(href, type, name);
|
||||
this.networkType = networkType;
|
||||
}
|
||||
|
||||
protected NetworkReference() {
|
||||
private NetworkReference() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.software;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="OperatingSystem">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
||||
public class OperatingSystem extends Resource<OperatingSystem> {
|
||||
|
||||
//TODO There are other fields
|
||||
|
||||
|
@ -43,24 +46,24 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromNamedResource(this);
|
||||
return new Builder().fromOperatingSystem(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<OperatingSystem> {
|
||||
public static class Builder extends Resource.Builder<OperatingSystem> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OperatingSystem build() {
|
||||
return new OperatingSystem(href, type, name);
|
||||
return new OperatingSystem(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<OperatingSystem> in) {
|
||||
public Builder fromResource(Resource<OperatingSystem> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
|
@ -68,8 +71,12 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<OperatingSystem> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
public Builder fromBaseResource(BaseResource<OperatingSystem> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
public Builder fromOperatingSystem(OperatingSystem in) {
|
||||
return fromResource(in);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,6 +103,22 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -106,11 +129,11 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
|
||||
}
|
||||
|
||||
public OperatingSystem(URI href, String type, String name) {
|
||||
super(href, type, name);
|
||||
private OperatingSystem(URI href, String type, Set<Link> links, Set<Action> actions, String name) {
|
||||
super(href, type, name, links, actions);
|
||||
}
|
||||
|
||||
protected OperatingSystem() {
|
||||
private OperatingSystem() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -19,17 +19,16 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.CustomizationOption;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="Template">
|
||||
|
@ -37,7 +36,7 @@ import java.net.URI;
|
|||
*
|
||||
*/
|
||||
@XmlRootElement(name = "Template")
|
||||
public class Template extends BaseNamedResource<Template> {
|
||||
public class Template extends Resource<Template> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
|
@ -52,9 +51,8 @@ public class Template extends BaseNamedResource<Template> {
|
|||
return new Builder().fromTask(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<Template> {
|
||||
public static class Builder extends Resource.Builder<Template> {
|
||||
//TODO There are additional fields
|
||||
protected Links links;
|
||||
protected OperatingSystem operatingSystem;
|
||||
protected String description;
|
||||
//protected ComputeMatrix computeMatrix;
|
||||
|
@ -65,14 +63,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
protected CustomizationOption customization;
|
||||
//protected DeviceLicensedSoftware licensedSoftware;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.Template#getLinks
|
||||
*/
|
||||
public Builder links(Links links) {
|
||||
this.links = links;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.Template#getOperatingSystem
|
||||
*/
|
||||
|
@ -131,18 +121,29 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
@Override
|
||||
public Template build() {
|
||||
return new Template(href, type, name, links, operatingSystem, description, processor, memory, storage, networkAdapters, customization);
|
||||
return new Template(href, type, links, actions, name, operatingSystem, description, processor, memory, storage, networkAdapters, customization);
|
||||
}
|
||||
|
||||
public Builder fromTask(Template in) {
|
||||
return fromResource(in).description(in.getDescription());
|
||||
return fromResource(in).description(in.getDescription())
|
||||
.operatingSystem(in.getOperatingSystem()).processor(in.getProcessor())
|
||||
.memory(in.getMemory()).storage(in.getStorage()).networkAdapters(in.getNetworkAdapters())
|
||||
.customization(in.getCustomization());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Template> in) {
|
||||
public Builder fromBaseResource(BaseResource<Template> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<Template> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
|
@ -162,6 +163,22 @@ public class Template extends BaseNamedResource<Template> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -169,10 +186,15 @@ public class Template extends BaseNamedResource<Template> {
|
|||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = false)
|
||||
protected Links links;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "OperatingSystem", required = false)
|
||||
protected OperatingSystem operatingSystem;
|
||||
|
@ -199,11 +221,10 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
//protected DeviceLicensedSoftware licensedSoftware;
|
||||
|
||||
private Template(URI href, String type, String name, @Nullable Links links, @Nullable OperatingSystem operatingSystem, @Nullable String description,
|
||||
private Template(URI href, String type, Set<Link> links, Set<Action> actions, String name, @Nullable OperatingSystem operatingSystem, @Nullable String description,
|
||||
@Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
@Nullable TemplateStorage storage, @Nullable int networkAdapters, @Nullable CustomizationOption customization) {
|
||||
super(href, type, name);
|
||||
this.links = links;
|
||||
super(href, type, name, links, actions);
|
||||
this.operatingSystem = operatingSystem;
|
||||
this.description = description;
|
||||
this.processor = processor;
|
||||
|
@ -217,10 +238,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Links getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -262,8 +279,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
return false;
|
||||
if (description != null ? !description.equals(template.description) : template.description != null)
|
||||
return false;
|
||||
if (links != null ? !links.equals(template.links) : template.links != null)
|
||||
return false;
|
||||
if (memory != null ? !memory.equals(template.memory) : template.memory != null)
|
||||
return false;
|
||||
if (operatingSystem != null ? !operatingSystem.equals(template.operatingSystem) : template.operatingSystem != null)
|
||||
|
@ -279,7 +294,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||
result = 31 * result + (operatingSystem != null ? operatingSystem.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (processor != null ? processor.hashCode() : 0);
|
||||
|
@ -292,7 +306,7 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+ links+", operatingSystem="+ operatingSystem+
|
||||
return super.string()+", operatingSystem="+ operatingSystem+
|
||||
", description="+ description+", processor="+ processor+
|
||||
", memory="+ memory+", storage="+ storage+
|
||||
", networkAdapters="+ networkAdapters+", customization="+ customization;
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual TemplateCategory elements.
|
||||
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||
* <xs:complexType name="TemplateCategories">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateCategories {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateCategories(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateCategories#getTemplateCategories()
|
||||
*/
|
||||
public Builder categories(Set<TemplateCategory> categories) {
|
||||
this.categories = Sets.newLinkedHashSet(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addCategory(TemplateCategory category) {
|
||||
categories.add(checkNotNull(category,"category"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCategories build() {
|
||||
return new TemplateCategories(categories);
|
||||
}
|
||||
|
||||
public Builder fromTemplateCategories(TemplateCategories in) {
|
||||
return categories(in.getTemplateCategories());
|
||||
}
|
||||
}
|
||||
|
||||
private TemplateCategories() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private TemplateCategories(Set<TemplateCategory> categories) {
|
||||
this.categories = Sets.newLinkedHashSet(categories);
|
||||
}
|
||||
|
||||
@XmlElement(name = "Category")
|
||||
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<TemplateCategory> getTemplateCategories() {
|
||||
return Collections.unmodifiableSet(categories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateCategories that = (TemplateCategories) o;
|
||||
|
||||
if (categories != null ? !categories.equals(that.categories) : that.categories != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return categories != null ? categories.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ categories.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="TemplateCategory">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateCategory {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateCategory(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String name;
|
||||
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateCategory#getTemplateOperatingSystems
|
||||
*/
|
||||
public Builder templateOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||
this.operatingSystems = Sets.newLinkedHashSet(checkNotNull(operatingSystems, "operatingSystems"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TemplateCategory#getName
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateCategory build() {
|
||||
return new TemplateCategory(name,operatingSystems);
|
||||
}
|
||||
|
||||
public Builder fromTemplateCategory(TemplateCategory in) {
|
||||
return name(in.getName()).templateOperatingSystems(in.getTemplateOperatingSystems());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Name", required = false)
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "OperatingSystems", required = false)
|
||||
private TemplateOperatingSystems operatingSystems = TemplateOperatingSystems.builder().build();
|
||||
|
||||
private TemplateCategory(@Nullable String name, Set<TemplateOperatingSystem> operatingSystems) {
|
||||
this.name = name;
|
||||
this.operatingSystems = TemplateOperatingSystems.builder().operatingSystems(operatingSystems).build();
|
||||
}
|
||||
|
||||
protected TemplateCategory() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<TemplateOperatingSystem> getTemplateOperatingSystems() {
|
||||
return operatingSystems.getTemplateOperatingSystems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateCategory that = (TemplateCategory) o;
|
||||
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
if (operatingSystems != null ? !operatingSystems.equals(that.operatingSystems) : that.operatingSystems != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (operatingSystems != null ? operatingSystems.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[name="+name+", +operatingSystems="+operatingSystems+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual TemplateFamily elements.
|
||||
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||
* <xs:complexType name="TemplateFamilies">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateFamilies {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateFamilies(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateFamilies#getTemplateFamilies()
|
||||
*/
|
||||
public Builder families(Set<TemplateFamily> families) {
|
||||
this.families = Sets.newLinkedHashSet(checkNotNull(families, "families"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addFamily(TemplateFamily family) {
|
||||
families.add(checkNotNull(family,"family"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateFamilies build() {
|
||||
return new TemplateFamilies(families);
|
||||
}
|
||||
|
||||
public Builder fromTemplateFamilies(TemplateFamilies in) {
|
||||
return families(in.getTemplateFamilies());
|
||||
}
|
||||
}
|
||||
|
||||
private TemplateFamilies() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private TemplateFamilies(Set<TemplateFamily> families) {
|
||||
this.families = Sets.newLinkedHashSet(families);
|
||||
}
|
||||
|
||||
@XmlElement(name = "Family")
|
||||
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<TemplateFamily> getTemplateFamilies() {
|
||||
return Collections.unmodifiableSet(families);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateFamilies that = (TemplateFamilies) o;
|
||||
|
||||
if (families != null ? !families.equals(that.families) : that.families != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return families != null ? families.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ families.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="TemplateFamily">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateFamily {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateFamily(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String name;
|
||||
private Set<TemplateCategory> categories = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateFamily#getTemplateCategories
|
||||
*/
|
||||
public Builder templateCategories(Set<TemplateCategory> categories) {
|
||||
this.categories = Sets.newLinkedHashSet(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TemplateFamily#getName
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateFamily build() {
|
||||
return new TemplateFamily(name,categories);
|
||||
}
|
||||
|
||||
public Builder fromTemplateFamily(TemplateFamily in) {
|
||||
return name(in.getName()).templateCategories(in.getTemplateCategories());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Name", required = false)
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "Categories", required = false)
|
||||
private TemplateCategories categories = TemplateCategories.builder().build();
|
||||
|
||||
private TemplateFamily(@Nullable String name, Set<TemplateCategory> categories) {
|
||||
this.name = name;
|
||||
this.categories = TemplateCategories.builder().categories(categories).build();
|
||||
}
|
||||
|
||||
protected TemplateFamily() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<TemplateCategory> getTemplateCategories() {
|
||||
return categories.getTemplateCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateFamily that = (TemplateFamily) o;
|
||||
|
||||
if (categories != null ? !categories.equals(that.categories) : that.categories != null)
|
||||
return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (categories != null ? categories.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[name="+name+", +categories="+categories+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="TemplateOperatingSystem">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateOperatingSystem {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateOperatingSystem(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String name;
|
||||
private Set<NamedResource> templates = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateOperatingSystem#getTemplates
|
||||
*/
|
||||
public Builder templates(Set<NamedResource> templates) {
|
||||
this.templates = Sets.newLinkedHashSet(checkNotNull(templates, "templates"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TemplateOperatingSystem#getName
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateOperatingSystem build() {
|
||||
return new TemplateOperatingSystem(name,templates);
|
||||
}
|
||||
|
||||
public Builder fromTemplateOperatingSystem(TemplateOperatingSystem in) {
|
||||
return name(in.getName()).templates(in.getTemplates());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Name", required = false)
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "Templates", required = false)
|
||||
private TemplateReferences templates = TemplateReferences.builder().build();
|
||||
|
||||
private TemplateOperatingSystem(@Nullable String name, Set<NamedResource> templates) {
|
||||
this.name = name;
|
||||
this.templates = TemplateReferences.builder().templateReferences(checkNotNull(templates,"templates")).build();
|
||||
}
|
||||
|
||||
private TemplateOperatingSystem() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<NamedResource> getTemplates() {
|
||||
return templates.getTemplateReferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateOperatingSystem that = (TemplateOperatingSystem) o;
|
||||
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
if (templates != null ? !templates.equals(that.templates) : that.templates != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (templates != null ? templates.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[name="+name+", +templates="+templates+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual TemplateOperatingSystem elements.
|
||||
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||
* <xs:complexType name="TemplateOperatingSystems">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateOperatingSystems {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateOperatingSystems(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateOperatingSystems#getTemplateOperatingSystems()
|
||||
*/
|
||||
public Builder operatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||
this.operatingSystems = Sets.newLinkedHashSet(checkNotNull(operatingSystems, "operatingSystems"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addOperatingSystem(TemplateOperatingSystem operatingSystem) {
|
||||
operatingSystems.add(checkNotNull(operatingSystem,"operatingSystem"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateOperatingSystems build() {
|
||||
return new TemplateOperatingSystems(operatingSystems);
|
||||
}
|
||||
|
||||
public Builder fromTemplateOperatingSystems(TemplateOperatingSystems in) {
|
||||
return operatingSystems(in.getTemplateOperatingSystems());
|
||||
}
|
||||
}
|
||||
|
||||
private TemplateOperatingSystems() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private TemplateOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||
this.operatingSystems = Sets.newLinkedHashSet(operatingSystems);
|
||||
}
|
||||
|
||||
@XmlElement(name = "OperatingSystem")
|
||||
private Set<TemplateOperatingSystem> operatingSystems = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<TemplateOperatingSystem> getTemplateOperatingSystems() {
|
||||
return Collections.unmodifiableSet(operatingSystems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateOperatingSystems that = (TemplateOperatingSystems) o;
|
||||
|
||||
if (operatingSystems != null ? !operatingSystems.equals(that.operatingSystems) : that.operatingSystems != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return operatingSystems != null ? operatingSystems.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ operatingSystems.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Wraps individual TemplateReference elements.
|
||||
* Needed because parsing is done with JAXB and it does not handle Generic collections
|
||||
* <xs:complexType name="TemplateReferences">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateReferences {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTemplateReferences(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<NamedResource> templateReferences = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.TemplateReferences#getTemplateReferences()
|
||||
*/
|
||||
public Builder templateReferences(Set<NamedResource> templateReferences) {
|
||||
this.templateReferences = Sets.newLinkedHashSet(checkNotNull(templateReferences, "templateReferences"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addTemplateReference(NamedResource templateReference) {
|
||||
templateReferences.add(checkNotNull(templateReference,"templateReference"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateReferences build() {
|
||||
return new TemplateReferences(templateReferences);
|
||||
}
|
||||
|
||||
public Builder fromTemplateReferences(TemplateReferences in) {
|
||||
return templateReferences(in.getTemplateReferences());
|
||||
}
|
||||
}
|
||||
|
||||
private TemplateReferences() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private TemplateReferences(Set<NamedResource> templateReferences) {
|
||||
this.templateReferences = Sets.newLinkedHashSet(templateReferences);
|
||||
}
|
||||
|
||||
@XmlElement(name = "Template")
|
||||
private Set<NamedResource> templateReferences = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<NamedResource> getTemplateReferences() {
|
||||
return Collections.unmodifiableSet(templateReferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateReferences that = (TemplateReferences) o;
|
||||
|
||||
if (templateReferences != null ? !templateReferences.equals(that.templateReferences) : that.templateReferences != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return templateReferences != null ? templateReferences.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ templateReferences.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -32,13 +34,13 @@ import java.util.Set;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Templates is more than a simple wrapper as it extends BaseResource.
|
||||
* <xs:complexType name="Templates">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "Templates")
|
||||
public class Templates extends BaseResource<Templates> {
|
||||
|
||||
public class Templates extends Resource<Templates> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
|
@ -53,31 +55,39 @@ public class Templates extends BaseResource<Templates> {
|
|||
return new Builder().fromTemplates(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<Templates> {
|
||||
private Links links = Links.builder().build();
|
||||
public static class Builder extends Resource.Builder<Templates> {
|
||||
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see Templates#getLinks
|
||||
* @see Templates#getTemplateFamilies
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
public Builder families(Set<TemplateFamily> families) {
|
||||
this.families =(checkNotNull(families,"families"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Templates build() {
|
||||
return new Templates(href, type, links);
|
||||
return new Templates(href, type, name, links, actions, families);
|
||||
}
|
||||
|
||||
public Builder fromTemplates(Templates in) {
|
||||
return fromResource(in).links(in.getLinks());
|
||||
return fromResource(in).families(in.getTemplateFamilies());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Templates> in) {
|
||||
public Builder fromBaseResource(BaseResource<Templates> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<Templates> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
|
@ -97,6 +107,30 @@ public class Templates extends BaseResource<Templates> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -107,15 +141,15 @@ public class Templates extends BaseResource<Templates> {
|
|||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = true)
|
||||
private Links links = Links.builder().build();
|
||||
@XmlElement(name = "Families", required = false)
|
||||
private TemplateFamilies families;
|
||||
|
||||
public Templates(URI href, String type, Links links ) {
|
||||
super(href, type);
|
||||
this.links = checkNotNull(links, "links");
|
||||
private Templates(URI href, String type, String name, Set<Link> links, Set<Action> actions, Set<TemplateFamily> families) {
|
||||
super(href, type, name, links, actions);
|
||||
this.families = TemplateFamilies.builder().families(families).build();
|
||||
}
|
||||
|
||||
protected Templates() {
|
||||
private Templates() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
@ -123,8 +157,33 @@ public class Templates extends BaseResource<Templates> {
|
|||
return Collections.unmodifiableSet(links.getLinks());
|
||||
}
|
||||
|
||||
public Set<TemplateFamily> getTemplateFamilies() {
|
||||
return families.getTemplateFamilies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Templates templates = (Templates) o;
|
||||
|
||||
if (families != null ? !families.equals(templates.families) : templates.families != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (families != null ? families.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+links;
|
||||
return super.string()+", families="+families;
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ package org.jclouds.tmrk.enterprisecloud.domain.vm;
|
|||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.software.ToolsStatus;
|
||||
|
||||
|
@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*
|
||||
*/
|
||||
@XmlRootElement(name = "VirtualMachine")
|
||||
public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
||||
public class VirtualMachine extends Resource<VirtualMachine> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
|
@ -60,10 +60,8 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
return new Builder().fromVirtualMachine(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<VirtualMachine> {
|
||||
public static class Builder extends Resource.Builder<VirtualMachine> {
|
||||
//TODO There are some more fields
|
||||
private Links links = Links.builder().build();
|
||||
private Actions actions = Actions.builder().build();
|
||||
private Tasks tasks = Tasks.builder().build();
|
||||
private String description;
|
||||
private VirtualMachineStatus status;
|
||||
|
@ -77,23 +75,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
private HardwareConfiguration hardwareConfiguration;
|
||||
private VirtualMachineIpAddresses ipAddresses = new VirtualMachineIpAddresses();
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getLinks
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getActions
|
||||
*/
|
||||
public Builder actions(Set<Action> actions) {
|
||||
checkNotNull(actions,"actions");
|
||||
this.actions = Actions.builder().actions(actions).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getTasks
|
||||
*/
|
||||
|
@ -198,10 +179,8 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
}
|
||||
|
||||
public Builder fromVirtualMachine(VirtualMachine in) {
|
||||
return fromNamedResource(in)
|
||||
.links(in.getLinks())
|
||||
return fromResource(in)
|
||||
.tasks(in.getTasks())
|
||||
.actions(in.getActions())
|
||||
.description(in.getDescription())
|
||||
.layout(in.getLayout())
|
||||
.status(in.getStatus())
|
||||
|
@ -218,16 +197,16 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
public Builder fromBaseResource(BaseResource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
public Builder fromResource(Resource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,6 +225,22 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -259,21 +254,17 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
// TODO Other fields?
|
||||
super.fromAttributes(attributes);
|
||||
if (attributes.containsKey("description"))
|
||||
description(attributes.get("description"));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = true)
|
||||
private Links links = Links.builder().build();
|
||||
|
||||
@XmlElement(name = "Tasks", required = true)
|
||||
private Tasks tasks = Tasks.builder().build();
|
||||
|
||||
@XmlElement(name = "Actions", required = true)
|
||||
private Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlElement(name = "Description", required = true)
|
||||
private String description;
|
||||
|
||||
|
@ -304,14 +295,12 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
@XmlElement(name = "IpAddresses", required = false)
|
||||
private VirtualMachineIpAddresses ipAddresses = new VirtualMachineIpAddresses();
|
||||
|
||||
public VirtualMachine(URI href, String type, String name, Tasks tasks, Actions actions, Links links, String description, @Nullable Layout layout,
|
||||
private VirtualMachine(URI href, String type, String name, Tasks tasks, Set<Action> actions, Set<Link> links, String description, @Nullable Layout layout,
|
||||
VirtualMachineStatus status, boolean poweredOn, @Nullable ToolsStatus toolsStatus, @Nullable VirtualMachineMediaStatus mediaStatus, boolean customizationPending,
|
||||
@Nullable OperatingSystem operatingSystem, @Nullable HardwareConfiguration hardwareConfiguration, @Nullable VirtualMachineIpAddresses ipAddresses) {
|
||||
super(href, type, name);
|
||||
super(href, type, name, links, actions);
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.links = checkNotNull(links, "links");
|
||||
this.tasks = checkNotNull(tasks, "tasks");
|
||||
this.actions = checkNotNull(actions, "actions");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.ipAddresses = checkNotNull(ipAddresses, "ipAddresses");
|
||||
|
||||
|
@ -324,29 +313,20 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
this.hardwareConfiguation = hardwareConfiguration;
|
||||
}
|
||||
|
||||
protected VirtualMachine() {
|
||||
private VirtualMachine() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(links.getLinks());
|
||||
}
|
||||
|
||||
/**
|
||||
* refers to tasks regarding the virtual machine.
|
||||
* Only the most recent tasks, up to twenty, are returned.
|
||||
* Use the href to retrieve the complete list of tasks.
|
||||
* @return most recent tasks
|
||||
*/
|
||||
/**
|
||||
* refers to tasks regarding the virtual machine.
|
||||
* Only the most recent tasks, up to twenty, are returned.
|
||||
* Use the href to retrieve the complete list of tasks.
|
||||
* @return most recent tasks
|
||||
*/
|
||||
public Set<Task> getTasks() {
|
||||
return Collections.unmodifiableSet(tasks.getTasks());
|
||||
}
|
||||
|
||||
public Set<Action> getActions() {
|
||||
return Collections.unmodifiableSet(actions.getActions());
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -409,7 +389,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
if (customizationPending != that.customizationPending) return false;
|
||||
if (poweredOn != that.poweredOn) return false;
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (hardwareConfiguation != null ? !hardwareConfiguation.equals(that.hardwareConfiguation) : that.hardwareConfiguation != null)
|
||||
|
@ -417,7 +396,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
if (!ipAddresses.equals(that.ipAddresses)) return false;
|
||||
if (layout != null ? !layout.equals(that.layout) : that.layout != null)
|
||||
return false;
|
||||
if (!links.equals(that.links)) return false;
|
||||
if (mediaStatus != that.mediaStatus) return false;
|
||||
if (operatingSystem != null ? !operatingSystem.equals(that.operatingSystem) : that.operatingSystem != null)
|
||||
return false;
|
||||
|
@ -431,9 +409,7 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + links.hashCode();
|
||||
result = 31 * result + tasks.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (layout != null ? layout.hashCode() : 0);
|
||||
result = 31 * result + (status != null ? status.hashCode() : 0);
|
||||
|
@ -449,7 +425,7 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+links+", tasks="+tasks+", actions="+actions+", description="+description+", layout="+layout+
|
||||
return super.string()+", tasks="+tasks+", description="+description+", layout="+layout+
|
||||
", status="+status+", poweredOn="+poweredOn+", toolsStatus="+toolsStatus+", mediaStatus="+mediaStatus+
|
||||
", customizationPending="+customizationPending+", operatingSystem="+operatingSystem+", hardwareConfiguration="+hardwareConfiguation+
|
||||
", ipAddresses="+ipAddresses;
|
||||
|
|
|
@ -22,10 +22,13 @@ import org.jclouds.javax.annotation.Nullable;
|
|||
import org.jclouds.tmrk.enterprisecloud.domain.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.hardware.DiskConfigurationOption;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="VirtualMachineConfigurationOptions">
|
||||
|
@ -33,7 +36,7 @@ import java.net.URI;
|
|||
*
|
||||
*/
|
||||
@XmlRootElement(name = "VirtualMachineConfigurationOptions")
|
||||
public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMachineConfigurationOptions> {
|
||||
public class VirtualMachineConfigurationOptions extends Resource<VirtualMachineConfigurationOptions> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
|
@ -48,7 +51,7 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
return new Builder().fromVirtualMachineConfigurationOptions(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<VirtualMachineConfigurationOptions> {
|
||||
public static class Builder extends Resource.Builder<VirtualMachineConfigurationOptions> {
|
||||
|
||||
protected ConfigurationOptionRange processor;
|
||||
protected ResourceCapacityRange memory;
|
||||
|
@ -99,7 +102,7 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
|
||||
@Override
|
||||
public VirtualMachineConfigurationOptions build() {
|
||||
return new VirtualMachineConfigurationOptions(href, type, processor, memory, disk, networkAdapter, customization);
|
||||
return new VirtualMachineConfigurationOptions(href, type, name, links, actions, processor, memory, disk, networkAdapter, customization);
|
||||
}
|
||||
|
||||
public Builder fromVirtualMachineConfigurationOptions(VirtualMachineConfigurationOptions in) {
|
||||
|
@ -114,10 +117,18 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<VirtualMachineConfigurationOptions> in) {
|
||||
public Builder fromResource(Resource<VirtualMachineConfigurationOptions> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<VirtualMachineConfigurationOptions> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -134,6 +145,29 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Processor", required = false)
|
||||
|
@ -151,9 +185,9 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
@XmlElement(name = "Customization", required = false)
|
||||
private CustomizationOption customization;
|
||||
|
||||
private VirtualMachineConfigurationOptions(URI href, String type, @Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
private VirtualMachineConfigurationOptions(URI href, String type, String name, Set<Link> links, Set<Action> actions, @Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
@Nullable DiskConfigurationOption disk, @Nullable ConfigurationOptionRange networkAdapter, @Nullable CustomizationOption customization) {
|
||||
super(href, type);
|
||||
super(href, type, name, links, actions);
|
||||
this.processor = processor;
|
||||
this.memory = memory;
|
||||
this.disk = disk;
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface TemplateClient {
|
|||
|
||||
/**
|
||||
* The Get Templates call returns information regarding templates defined in a compute pool.
|
||||
* Note that Templates are not a simple wrapper around template objects.
|
||||
* Note that Templates are not a simple wrapper around template objects, so if not found returns null.
|
||||
* Once the desired template is located getTemplate must be called to retrieve all the attached information
|
||||
* @param uri compute pool identifier
|
||||
* @return the templates
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.template.*;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TemplateClientLiveTest}
|
||||
* TODO: don't hard-code uri's it should be possible to determine them but that means chaining the tests potentially.
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "live", testName = "TemplateClientLiveTest")
|
||||
public class TemplateClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTest {
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
super.setupClient();
|
||||
client = context.getApi().getTemplateClient();
|
||||
}
|
||||
|
||||
private TemplateClient client;
|
||||
|
||||
public void testGetTemplates() throws Exception {
|
||||
Templates templates = client.getTemplates(new URI("/cloudapi/ecloud/templates/computepools/89"));
|
||||
for(TemplateFamily family: templates.getTemplateFamilies()) {
|
||||
for(TemplateCategory category: family.getTemplateCategories()) {
|
||||
for(TemplateOperatingSystem os: category.getTemplateOperatingSystems()) {
|
||||
for(NamedResource templateReference: os.getTemplates()) {
|
||||
testTemplate(templateReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testTemplate(NamedResource templateReference) {
|
||||
Template template = client.getTemplate(templateReference.getHref());
|
||||
assertNotNull(template);
|
||||
assertNotNull(template.getDescription());
|
||||
}
|
||||
|
||||
public void testGetTemplatesWhenMissing() throws Exception {
|
||||
Templates templates = client.getTemplates(new URI("/cloudapi/ecloud/templates/computepools/-1"));
|
||||
assertNull(templates);
|
||||
}
|
||||
|
||||
public void testGetTemplateWhenMissing() throws Exception {
|
||||
Template template = client.getTemplate(new URI("/cloudapi/ecloud/templates/-1/computepools/89"));
|
||||
assertNull(template);
|
||||
}
|
||||
}
|
|
@ -101,7 +101,7 @@ public class TemplateJAXBParsingTest extends BaseRestClientTest {
|
|||
InputStream is = getClass().getResourceAsStream("/template.xml");
|
||||
Template template = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(template.getLinks().getLinks());
|
||||
assertLinks(template.getLinks());
|
||||
assertOperatingSystem(template.getOperatingSystem());
|
||||
assertEquals(template.getDescription(),"");
|
||||
assertProcessor(template.getProcessor());
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.CustomizationOption;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.template.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.TemplateAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for Templates
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "TemplatesJAXBParsingTest")
|
||||
public class TemplatesJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module>of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
public void testParseTemplates() throws Exception {
|
||||
|
||||
Method method = TemplateAsyncClient.class.getMethod("getTemplates", URI.class);
|
||||
HttpRequest request = factory(TemplateAsyncClient.class).createRequest(method,new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, Templates> parser = (Function<HttpResponse, Templates>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/templates.xml");
|
||||
Templates templates = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(templates.getLinks());
|
||||
assertFamilies(templates.getTemplateFamilies());
|
||||
}
|
||||
|
||||
private void assertLinks(Set<Link> links) {
|
||||
assertEquals(links.size(),1);
|
||||
Link link = Iterables.getOnlyElement(links);
|
||||
assertEquals(link.getName(),"Default Compute Pool");
|
||||
}
|
||||
|
||||
private void assertFamilies(Set<TemplateFamily> families) {
|
||||
assertEquals(families.size(),1);
|
||||
TemplateFamily family = Iterables.getOnlyElement(families);
|
||||
assertEquals(family.getName(),"Standard Templates");
|
||||
assertCategories(family.getTemplateCategories());
|
||||
}
|
||||
|
||||
private void assertCategories(Set<TemplateCategory> categories) {
|
||||
assertEquals(categories.size(),1);
|
||||
TemplateCategory category = Iterables.getOnlyElement(categories);
|
||||
assertEquals(category.getName(),"OS Only");
|
||||
assertOperatingSystems(category.getTemplateOperatingSystems());
|
||||
}
|
||||
|
||||
private void assertOperatingSystems(Set<TemplateOperatingSystem> operatingSystems) {
|
||||
assertEquals(operatingSystems.size(),2);
|
||||
TemplateOperatingSystem windows = Iterables.get(operatingSystems, 0);
|
||||
assertEquals(windows.getName(),"Windows");
|
||||
assertEquals(windows.getTemplates().size(),4);
|
||||
|
||||
TemplateOperatingSystem linux = Iterables.get(operatingSystems, 1);
|
||||
assertEquals(linux.getName(),"Linux");
|
||||
assertEquals(linux.getTemplates().size(),2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue