Glesys api unit test and javadoc improvements

This commit is contained in:
Adam Lowe 2011-12-15 15:29:02 +00:00
parent a1c4ec13ca
commit 7d5a791071
10 changed files with 315 additions and 215 deletions

View File

@ -20,13 +20,11 @@ package org.jclouds.glesys.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
@ -36,175 +34,198 @@ import com.google.gson.annotations.SerializedName;
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_allowedarguments" /> * @see <a href="https://customer.glesys.com/api.php?a=doc#server_allowedarguments" />
*/ */
public class ServerAllowedArguments { public class ServerAllowedArguments {
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
public static class Builder { public static class Builder {
private List<Integer> diskSizes; private List<Integer> diskSizes;
private List<Integer> memorySizes; private List<Integer> memorySizes;
private List<Integer> cpuCores; private List<Integer> cpuCores;
private List<String> templates; private List<String> templates;
private List<Integer> transfers; private List<Integer> transfers;
private List<String> dataCenters; private List<String> dataCenters;
public Builder diskSizes(Integer... sizes) { public Builder diskSizes(Integer... sizes) {
return diskSizes(Arrays.<Integer>asList(sizes)); return diskSizes(Arrays.<Integer>asList(sizes));
} }
public Builder diskSizes(List<Integer> sizes) { public Builder diskSizes(List<Integer> sizes) {
this.diskSizes = sizes; this.diskSizes = sizes;
return this; return this;
} }
public Builder memorySizes(Integer... sizes) { public Builder memorySizes(Integer... sizes) {
return memorySizes(Arrays.<Integer>asList(sizes)); return memorySizes(Arrays.<Integer>asList(sizes));
} }
public Builder memorySizes(List<Integer> sizes) { public Builder memorySizes(List<Integer> sizes) {
this.memorySizes = sizes; this.memorySizes = sizes;
return this; return this;
} }
public Builder cpuCores(Integer... cpuCores) { public Builder cpuCores(Integer... cpuCores) {
this.cpuCores = Arrays.<Integer>asList(cpuCores); this.cpuCores = Arrays.<Integer>asList(cpuCores);
return this; return this;
} }
public Builder cpuCores(List<Integer> cpuCores) { public Builder cpuCores(List<Integer> cpuCores) {
this.cpuCores = cpuCores; this.cpuCores = cpuCores;
return this; return this;
} }
public Builder templates(String... templates) { public Builder templates(String... templates) {
return templates(Arrays.<String>asList(templates)); return templates(Arrays.<String>asList(templates));
} }
public Builder templates(List<String> templates) { public Builder templates(List<String> templates) {
this.templates = templates; this.templates = templates;
return this; return this;
} }
public Builder transfers(Integer... transfers) { public Builder transfers(Integer... transfers) {
return transfers(Arrays.<Integer>asList(transfers)); return transfers(Arrays.<Integer>asList(transfers));
} }
public Builder transfers(List<Integer> transfers) { public Builder transfers(List<Integer> transfers) {
this.transfers = transfers; this.transfers = transfers;
return this; return this;
} }
public Builder dataCenters(String... dataCenters) { public Builder dataCenters(String... dataCenters) {
return dataCenters(Arrays.<String>asList(dataCenters)); return dataCenters(Arrays.<String>asList(dataCenters));
} }
public Builder dataCenters(List<String> dataCenters) { public Builder dataCenters(List<String> dataCenters) {
this.dataCenters = dataCenters; this.dataCenters = dataCenters;
return this; return this;
} }
public ServerAllowedArguments build() { public ServerAllowedArguments build() {
return new ServerAllowedArguments(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters); return new ServerAllowedArguments(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
} }
public Builder fromAllowedArguments(ServerAllowedArguments in) { public Builder fromAllowedArguments(ServerAllowedArguments in) {
return diskSizes(in.getDiskSizes()) return diskSizes(in.getDiskSizes())
.memorySizes(in.getMemorySizes()) .memorySizes(in.getMemorySizes())
.cpuCores(in.getCpuCores()) .cpuCores(in.getCpuCores())
.templates(in.getTemplates()) .templates(in.getTemplates())
.transfers(in.getTransfers()) .transfers(in.getTransfers())
.dataCenters(in.getDataCenters()); .dataCenters(in.getDataCenters());
} }
} }
@SerializedName("disksize") @SerializedName("disksize")
private final List<Integer> diskSizes; private final List<Integer> diskSizes;
@SerializedName("memorysize") @SerializedName("memorysize")
private final List<Integer> memorySizes; private final List<Integer> memorySizes;
@SerializedName("cpucores") @SerializedName("cpucores")
private final List<Integer> cpuCores; private final List<Integer> cpuCores;
@SerializedName("template") @SerializedName("template")
private final List<String> templates; private final List<String> templates;
@SerializedName("transfer") @SerializedName("transfer")
private final List<Integer> transfers; private final List<Integer> transfers;
@SerializedName("datacenter") @SerializedName("datacenter")
private final List<String> dataCenters; private final List<String> dataCenters;
public ServerAllowedArguments(List<Integer> diskSizes, List<Integer> memorySizes, List<Integer> cpuCores, public ServerAllowedArguments(List<Integer> diskSizes, List<Integer> memorySizes, List<Integer> cpuCores,
List<String> templates, List<Integer> transfers, List<String> dataCenters) { List<String> templates, List<Integer> transfers, List<String> dataCenters) {
checkNotNull(diskSizes, "diskSizes"); checkNotNull(diskSizes, "diskSizes");
checkNotNull(memorySizes, "memorySizes"); checkNotNull(memorySizes, "memorySizes");
checkNotNull(cpuCores, "cpuCores"); checkNotNull(cpuCores, "cpuCores");
checkNotNull(templates, "templates"); checkNotNull(templates, "templates");
checkNotNull(transfers, "transfers"); checkNotNull(transfers, "transfers");
checkNotNull(dataCenters, "dataCenters"); checkNotNull(dataCenters, "dataCenters");
this.diskSizes = diskSizes; this.diskSizes = diskSizes;
this.memorySizes = memorySizes; this.memorySizes = memorySizes;
this.cpuCores = cpuCores; this.cpuCores = cpuCores;
this.templates = templates; this.templates = templates;
this.transfers = transfers; this.transfers = transfers;
this.dataCenters = dataCenters; this.dataCenters = dataCenters;
} }
public List<Integer> getDiskSizes() { /**
return diskSizes; * @return a list of disk sizes, in GB, that can be used for creating servers on this platform
} * @see org.jclouds.glesys.domain.ServerTemplate#getMinDiskSize()
*/
public List<Integer> getDiskSizes() {
return diskSizes;
}
public List<Integer> getMemorySizes() { /**
return memorySizes; * @return a list of memory sizes, in MB, that can be used for creating servers on this platform
} * @see org.jclouds.glesys.domain.ServerTemplate#getMinMemSize()
*/
public List<Integer> getMemorySizes() {
return memorySizes;
}
public List<Integer> getCpuCores() { /**
return cpuCores; * @return a list of which core counts can be used for creating servers on this platform
} */
public List<Integer> getCpuCores() {
return cpuCores;
}
public List<String> getTemplates() { /**
return templates; * @return a list of template names available for creating servers on this platform
} * @see org.jclouds.glesys.domain.ServerTemplate#getName()
*/
public List<String> getTemplates() {
return templates;
}
public List<Integer> getTransfers() { /**
return transfers; * @return the list of transfer settings available for creating servers on this platform
} */
public List<Integer> getTransfers() {
return transfers;
}
public List<String> getDataCenters() { /**
return dataCenters; * @return the list of datacenters available that support creating servers on this platform
} */
public List<String> getDataCenters() {
return dataCenters;
}
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) { if (this == object) {
return true; return true;
} }
if (object instanceof ServerAllowedArguments) { if (object instanceof ServerAllowedArguments) {
final ServerAllowedArguments other = (ServerAllowedArguments) object; final ServerAllowedArguments other = (ServerAllowedArguments) object;
return Objects.equal(diskSizes, other.diskSizes) return Objects.equal(diskSizes, other.diskSizes)
&& Objects.equal(memorySizes, other.memorySizes) && Objects.equal(memorySizes, other.memorySizes)
&& Objects.equal(cpuCores, other.cpuCores) && Objects.equal(cpuCores, other.cpuCores)
&& Objects.equal(templates, other.templates) && Objects.equal(templates, other.templates)
&& Objects.equal(transfers, other.transfers) && Objects.equal(transfers, other.transfers)
&& Objects.equal(dataCenters, other.dataCenters); && Objects.equal(dataCenters, other.dataCenters);
} else { } else {
return false; return false;
} }
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters); return Objects.hashCode(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
} }
@Override @Override
public String toString() { public String toString() {
checkNotNull(diskSizes, "diskSizes"); checkNotNull(diskSizes, "diskSizes");
checkNotNull(memorySizes, "memorySizes"); checkNotNull(memorySizes, "memorySizes");
checkNotNull(cpuCores, "cpuCores"); checkNotNull(cpuCores, "cpuCores");
checkNotNull(templates, "templates"); checkNotNull(templates, "templates");
checkNotNull(transfers, "transfers"); checkNotNull(transfers, "transfers");
checkNotNull(dataCenters, "dataCenters"); checkNotNull(dataCenters, "dataCenters");
Joiner commaJoiner = Joiner.on(", "); Joiner commaJoiner = Joiner.on(", ");
return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]", commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates), commaJoiner.join(transfers), commaJoiner.join(dataCenters)); return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]",
} commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates),
commaJoiner.join(transfers), commaJoiner.join(dataCenters));
}
} }

View File

@ -9,6 +9,39 @@ import com.google.common.base.Objects;
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" /> * @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" />
*/ */
public class ServerConsole { public class ServerConsole {
public static Builder builder() {
return new Builder();
}
public static class Builder {
private String host;
private int port;
private String password;
public Builder host(String host) {
this.host = host;
return this;
}
public Builder port(int port) {
this.port = port;
return this;
}
public Builder password(String password) {
this.password = password;
return this;
}
public ServerConsole build() {
return new ServerConsole(host, port, password);
}
public Builder fromServerConsole(ServerConsole in) {
return host(in.getHost()).port(in.getPort()).password(in.getPassword());
}
}
private final String host; private final String host;
private final int port; private final int port;
@ -20,19 +53,27 @@ public class ServerConsole {
this.password = password; this.password = password;
} }
/**
* @return the host name to use to connect to the server
*/
public String getHost() { public String getHost() {
return host; return host;
} }
/**
* @return the port to use to connect to the server
*/
public int getPort() { public int getPort() {
return port; return port;
} }
/**
* @return the password to use to connect to the server
*/
public String getPassword() { public String getPassword() {
return password; return password;
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) { if (this == object) {

View File

@ -22,7 +22,10 @@ package org.jclouds.glesys.domain;
import com.google.common.base.Objects; import com.google.common.base.Objects;
/** /**
* Represents detailed information about an available IP ip. * Represents detailed information about an available ip address of a new server.
*
* @author Adam Lowe
* @see ServerCreated
*/ */
public class ServerCreatedIp { public class ServerCreatedIp {
@ -69,14 +72,23 @@ public class ServerCreatedIp {
this.cost = cost; this.cost = cost;
} }
/**
* @return the IP version, ex. 4
*/
public int getVersion() { public int getVersion() {
return version; return version;
} }
/**
* @return the ip address of the new server
*/
public String getIp() { public String getIp() {
return ip; return ip;
} }
/**
* @return the cost of the ip address allocated to the new server
*/
public double getCost() { public double getCost() {
return cost; return cost;
} }
@ -91,7 +103,7 @@ public class ServerCreatedIp {
return Objects.equal(ip, other.ip) return Objects.equal(ip, other.ip)
&& Objects.equal(version, other.version) && Objects.equal(version, other.version)
&& Objects.equal(cost, other.cost); && Objects.equal(cost, other.cost);
} else { } else {
return false; return false;
} }
} }
@ -104,6 +116,6 @@ public class ServerCreatedIp {
@Override @Override
public String toString() { public String toString() {
return String.format("[ip=%s, version=%d, cost=%f]", return String.format("[ip=%s, version=%d, cost=%f]",
ip, version, cost); ip, version, cost);
} }
} }

View File

@ -23,6 +23,8 @@ import com.google.common.base.CaseFormat;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Valid states for a server hosted in a Glesys cloud
*
* @author Adam Lowe * @author Adam Lowe
* @see ServerStatus * @see ServerStatus
*/ */

View File

@ -4,11 +4,12 @@ import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
* Operating system template
*
* @author Adam Lowe * @author Adam Lowe
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_status" /> * @see <a href= "https://customer.glesys.com/api.php?a=doc#server_templates" />
*/ */
public class Template { public class ServerTemplate {
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
@ -46,11 +47,11 @@ public class Template {
return this; return this;
} }
public Template build() { public ServerTemplate build() {
return new Template(name, minDiskSize, minMemSize, os, platform); return new ServerTemplate(name, minDiskSize, minMemSize, os, platform);
} }
public Builder fromTemplate(Template in) { public Builder fromTemplate(ServerTemplate in) {
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform()); return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
} }
@ -64,7 +65,7 @@ public class Template {
private final String os; private final String os;
private final String platform; private final String platform;
public Template(String name, int minDiskSize, int minMemSize, String os, String platform) { public ServerTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
this.name = name; this.name = name;
this.minDiskSize = minDiskSize; this.minDiskSize = minDiskSize;
this.minMemSize = minMemSize; this.minMemSize = minMemSize;
@ -76,18 +77,32 @@ public class Template {
return name; return name;
} }
/**
* @return the minimum allowed disk size in GB
* @see org.jclouds.glesys.domain.ServerAllowedArguments#getDiskSizes()
*/
public int getMinDiskSize() { public int getMinDiskSize() {
return minDiskSize; return minDiskSize;
} }
/**
* @return the minimum allowed memory size in MB
* @see org.jclouds.glesys.domain.ServerAllowedArguments#getMemorySizes()
*/
public int getMinMemSize() { public int getMinMemSize() {
return minMemSize; return minMemSize;
} }
/**
* @return the name of the operating system type ex. "linux"
*/
public String getOs() { public String getOs() {
return os; return os;
} }
/**
* @return the name of the platform this template is available in, ex. "Xen"
*/
public String getPlatform() { public String getPlatform() {
return platform; return platform;
} }
@ -97,8 +112,8 @@ public class Template {
if (this == object) { if (this == object) {
return true; return true;
} }
if (object instanceof Template) { if (object instanceof ServerTemplate) {
final Template other = (Template) object; final ServerTemplate other = (ServerTemplate) object;
return Objects.equal(name, other.name) return Objects.equal(name, other.name)
&& Objects.equal(minDiskSize, other.minDiskSize) && Objects.equal(minDiskSize, other.minDiskSize)
&& Objects.equal(minMemSize, other.minMemSize) && Objects.equal(minMemSize, other.minMemSize)

View File

@ -28,13 +28,16 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* Represents an 'uptime' duration of server in a Glesys cloud
*
* @author Adam Lowe * @author Adam Lowe
* @see ServerStatus
*/ */
public class ServerUptime { public class ServerUptime {
private final long time; private final long time;
private final String timeString; private final String timeString;
public ServerUptime(long time) { private ServerUptime(long time) {
this.time = time; this.time = time;
long days = TimeUnit.SECONDS.toDays(time); long days = TimeUnit.SECONDS.toDays(time);
long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days)); long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days));
@ -65,14 +68,14 @@ public class ServerUptime {
} }
/** /**
* @param uptimeString a Glesys uptime string * @param uptimeString a Glesys uptime string, ex. "0 0 0 0 0 10 1 1"
*/ */
public static ServerUptime fromValue(String uptimeString) { public static ServerUptime fromValue(String uptimeString) {
return new ServerUptime(uptimeString); return new ServerUptime(uptimeString);
} }
/** /**
* @param time number of seconds * @param time number of seconds the server has been up
*/ */
public static ServerUptime fromValue(long time) { public static ServerUptime fromValue(long time) {
return new ServerUptime(time); return new ServerUptime(time);
@ -88,12 +91,12 @@ public class ServerUptime {
return true; return true;
} }
return object instanceof ServerUptime return object instanceof ServerUptime
&& time == ((ServerUptime) object).time; && Objects.equal(time, ((ServerUptime) object).getTime());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return 37 * (int) time; return Objects.hashCode(time);
} }
@Override @Override
@ -101,5 +104,4 @@ public class ServerUptime {
return timeString; return timeString;
} }
} }

View File

@ -36,6 +36,7 @@ import java.util.*;
* <p/> * <p/>
* *
* @author Adrian Cole * @author Adrian Cole
* @author Adam Lowe
* @see ServerClient * @see ServerClient
* @see <a href="https://customer.glesys.com/api.php" /> * @see <a href="https://customer.glesys.com/api.php" />
*/ */
@ -110,7 +111,7 @@ public interface ServerAsyncClient {
@Path("/server/templates/format/json") @Path("/server/templates/format/json")
@SelectJson("templates") @SelectJson("templates")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Map<String, Set<Template>>> getTemplates(); ListenableFuture<Map<String, Set<ServerTemplate>>> getTemplates();
/** /**
* @see ServerClient#stopServer * @see ServerClient#stopServer

View File

@ -18,17 +18,13 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.glesys.domain.*; import org.jclouds.glesys.domain.*;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.PathParam;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -36,6 +32,7 @@ import java.util.concurrent.TimeUnit;
* <p/> * <p/>
* *
* @author Adrian Cole * @author Adrian Cole
* @author Adam Lowe
* @see ServerAsyncClient * @see ServerAsyncClient
* @see <a href="https://customer.glesys.com/api.php" /> * @see <a href="https://customer.glesys.com/api.php" />
*/ */
@ -86,8 +83,18 @@ public interface ServerClient {
*/ */
ServerConsole getServerConsole(String id); ServerConsole getServerConsole(String id);
// TODO should these be squished into single sets? /**
Map<String, Set<Template>> getTemplates(); * Get information about the OS templates available
*
* @return a map of templates, keyed on platform
*/
Map<String, Set<ServerTemplate>> getTemplates();
/**
* Get information about valid arguments to #createServer for each platform
*
* @return a map of argument lists, keyed on platform
*/
Map<String, ServerAllowedArguments> getAllowedArguments(); Map<String, ServerAllowedArguments> getAllowedArguments();
/** /**
@ -156,5 +163,4 @@ public interface ServerClient {
void resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password); void resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password);
} }

View File

@ -46,45 +46,45 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
private ServerClient client; private ServerClient client;
@Test @Test
public void testCreateAndDestroyServer() throws Exception { public void testAllowedArguments() throws Exception {
// ServerCreated server = client.createServer("Falkenberg", "Xen", "jclouds-test-host", "Debian-6 x64", 10, 512, 1, "password", 500, null, null); Map<String,ServerAllowedArguments> templates = client.getAllowedArguments();
// System.out.println(server);
//
// boolean ready= false;
//
// for (int i=0; !ready && i<60; i++) {
// ServerStatus newStatus = client.getServerStatus(server.getId());
// if (newStatus.getState() == ServerState.RUNNING) {
// ready = true;
// break;
// }
// System.out.println(newStatus);
// Thread.sleep(100);
// }
//
// assertTrue(ready, "Server was not reported as running after 1 minute");
client.destroyServer("xm3054942", 0);
}
@Test
public void testListTemplates() throws Exception {
Map<String,Set<Template>> templates = client.getTemplates();
assertTrue(templates.containsKey("OpenVZ")); assertTrue(templates.containsKey("OpenVZ"));
assertTrue(templates.containsKey("Xen")); assertTrue(templates.containsKey("Xen"));
for(Template template : templates.get("OpenVZ")) { checkAllowedArguments(templates.get("OpenVZ"));
checkAllowedArguments(templates.get("Xen"));
}
private void checkAllowedArguments(ServerAllowedArguments t) {
assertNotNull(t);
assert t.getDataCenters().size() > 0 : t;
assert t.getCpuCores().size() > 0 : t;
assert t.getDiskSizes().size() > 0 : t;
assert t.getMemorySizes().size() > 0 : t;
assert t.getTemplates().size() > 0 : t;
assert t.getTransfers().size() > 0 : t;
assert t.getTransfers().size() > 0 : t;
}
@Test
public void testListTemplates() throws Exception {
Map<String,Set<ServerTemplate>> templates = client.getTemplates();
assertTrue(templates.containsKey("OpenVZ"));
assertTrue(templates.containsKey("Xen"));
for(ServerTemplate template : templates.get("OpenVZ")) {
checkTemplate(template, "OpenVZ"); checkTemplate(template, "OpenVZ");
} }
for(Template template : templates.get("Xen")) { for(ServerTemplate template : templates.get("Xen")) {
checkTemplate(template, "Xen"); checkTemplate(template, "Xen");
} }
} }
private void checkTemplate(Template t, String platform) { private void checkTemplate(ServerTemplate t, String platform) {
assertNotNull(t); assertNotNull(t);
assertNotNull(t.getName()); assertNotNull(t.getName());
assertNotNull(t.getOs()); assertNotNull(t.getOs());

View File

@ -37,7 +37,7 @@ import org.testng.annotations.Test;
* @author Adam Lowe * @author Adam Lowe
*/ */
@Test(groups = "unit", testName = "ParseServerTemplatesTest") @Test(groups = "unit", testName = "ParseServerTemplatesTest")
public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set<Template>>> { public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set<ServerTemplate>>> {
@Override @Override
public String resource() { public String resource() {
@ -47,8 +47,8 @@ public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set
@Override @Override
@SelectJson("templates") @SelectJson("templates")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Map<String, Set<Template>> expected() { public Map<String, Set<ServerTemplate>> expected() {
Map<String, Set<Template>> result = new LinkedHashMap<String, Set<Template>>(); Map<String, Set<ServerTemplate>> result = new LinkedHashMap<String, Set<ServerTemplate>>();
String[] vzNames = new String[]{ String[] vzNames = new String[]{
"Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit", "Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit",
@ -65,17 +65,17 @@ public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set
"Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web" "Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web"
}; };
result.put("OpenVZ", new HashSet<Template>()); result.put("OpenVZ", new HashSet<ServerTemplate>());
for (String name : vzNames) { for (String name : vzNames) {
result.get("OpenVZ").add(new Template(name, 5, 128, "linux", "OpenVZ")); result.get("OpenVZ").add(new ServerTemplate(name, 5, 128, "linux", "OpenVZ"));
} }
result.put("Xen", new HashSet<Template>()); result.put("Xen", new HashSet<ServerTemplate>());
for (String name : xenLinuxNames) { for (String name : xenLinuxNames) {
result.get("Xen").add(new Template(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen")); result.get("Xen").add(new ServerTemplate(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen"));
} }
for (String name : xenWindowsNames) { for (String name : xenWindowsNames) {
result.get("Xen").add(new Template(name, 20, 1024, "windows", "Xen")); result.get("Xen").add(new ServerTemplate(name, 20, 1024, "windows", "Xen"));
} }
return result; return result;