From ca69fbf0f7177fdfa24d3916b13a6e3f7491c28b Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 16:01:55 +0000 Subject: [PATCH 1/7] Issue 695: Added builder for Disks and removed setter, test. Used Actions builder externally and made constructor private --- .../tmrk/enterprisecloud/domain/Actions.java | 2 +- .../domain/hardware/Disks.java | 45 +++++++++++++- .../hardware/HardwareConfiguration.java | 6 +- .../domain/network/AssignedIpAddresses.java | 2 +- .../domain/vm/VirtualMachine.java | 4 +- .../enterprisecloud/hardware/DisksTest.java | 58 +++++++++++++++++++ 6 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java index 29b80c90a2..64ae9c5125 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java @@ -68,7 +68,7 @@ public class Actions { } } - public Actions() { + private Actions() { //For JAXB and builder use } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java index 3f336e6392..3334808429 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java @@ -35,9 +35,52 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class Disks { - private LinkedHashSet disks = Sets.newLinkedHashSet(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromDisks(this); + } + + public static class Builder { + + private Set disks = Sets.newLinkedHashSet(); + + /** + * @see Disks#getVirtualDisks() + */ + public Builder disks(Set disks) { + this.disks = Sets.newLinkedHashSet(checkNotNull(disks, "disks")); + return this; + } + + public Builder addDisk(VirtualDisk disk) { + disks.add(checkNotNull(disk,"disk")); + return this; + } + + public Disks build() { + return new Disks(disks); + } + + public Builder fromDisks(Disks in) { + return disks(in.getVirtualDisks()); + } + } @XmlElement(name = "Disk") + private LinkedHashSet disks = Sets.newLinkedHashSet(); + + private Disks() { + //For JAXB and builder use + } + + private Disks(Set disks) { + this.disks = Sets.newLinkedHashSet(disks); + } + public void setVirtualDisk(VirtualDisk disk) { checkNotNull(disk,"disk"); this.disks.add(disk); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java index 6378452550..e0ddd271d8 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java @@ -151,7 +151,7 @@ public class HardwareConfiguration extends BaseResource { } @XmlElement(name = "Actions", required = false) - private Actions actions = new Actions(); + private Actions actions = Actions.builder().build(); @XmlElement(name = "ProcessorCount", required = true) private int processorCount; @@ -160,14 +160,14 @@ public class HardwareConfiguration extends BaseResource { private Memory memory; @XmlElement(name = "Disks", required = false) - private Disks virtualDisks = new Disks(); + private Disks virtualDisks = Disks.builder().build(); @XmlElement(name = "Nics", required = false) private Nics virtualNics = new Nics(); public HardwareConfiguration(Set actions, int processorCount, @Nullable Memory memory, Set virtualDisks, Set virtualNics) { this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build(); - for( VirtualDisk disk: checkNotNull(virtualDisks, "virtualDisks")) this.virtualDisks.setVirtualDisk(disk); + this.virtualDisks = Disks.builder().disks(checkNotNull(virtualDisks,"virtualDisks")).build(); for( VirtualNic virtualNic: checkNotNull(virtualNics, "virtualNics")) this.virtualNics.setVirtualNic(virtualNic); this.processorCount = processorCount; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java index 301a1b7f91..52f880eeed 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java @@ -37,7 +37,7 @@ public class AssignedIpAddresses extends BaseResource { //TODO links @XmlElement(name = "Actions", required = true) - private Actions actions = new Actions(); + private Actions actions = Actions.builder().build(); @XmlElement(name = "Networks", required = true) private DeviceNetworks networks = new DeviceNetworks(); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java index 29ff17e012..affdb76981 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java @@ -63,7 +63,7 @@ public class VirtualMachine extends BaseNamedResource { public static class Builder extends BaseNamedResource.Builder { //TODO There are some more fields private Links links = new Links(); - private Actions actions = new Actions(); + private Actions actions = Actions.builder().build(); private Tasks tasks = new Tasks(); private String description; private VirtualMachineStatus status; @@ -275,7 +275,7 @@ public class VirtualMachine extends BaseNamedResource { private Tasks tasks = new Tasks(); @XmlElement(name = "Actions", required = true) - private Actions actions = new Actions(); + private Actions actions = Actions.builder().build(); @XmlElement(name = "Description", required = true) private String description; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java new file mode 100644 index 0000000000..54ce6db170 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java @@ -0,0 +1,58 @@ +/** + * 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.hardware; + +import org.jclouds.tmrk.enterprisecloud.domain.Size; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.Disks; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.VirtualDisk; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URISyntaxException; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "DisksTest") +public class DisksTest { + + private VirtualDisk disk; + private Disks disks; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + disk = VirtualDisk.builder().index(0).name("test disk").size(Size.builder().value(1).unit("GB").build()).build(); + disks = Disks.builder().addDisk(disk).build(); + } + + @Test + public void testAddDisk() throws URISyntaxException { + VirtualDisk disk2 = VirtualDisk.builder().index(1).name("test disk 1").size(Size.builder().value(1).unit("GB").build()).build(); + Disks twoDisks = disks.toBuilder().addDisk(disk2).build(); + Set virtualDisks = twoDisks.getVirtualDisks(); + + assertEquals(2, virtualDisks.size()); + assertTrue(virtualDisks.contains(disk)); + assertTrue(virtualDisks.contains(disk2)); + } +} From e2d7b66b0cba847dd44f4833b711082e2edd1b79 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 16:44:28 +0000 Subject: [PATCH 2/7] Issue 695: Created builder for links and fixed order of constructor args --- .../tmrk/enterprisecloud/domain/Link.java | 2 +- .../tmrk/enterprisecloud/domain/Links.java | 87 ++++++++++++++----- .../domain/vm/VirtualMachine.java | 7 +- .../enterprisecloud/domain/LinksTest.java | 58 +++++++++++++ 4 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/LinksTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Link.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Link.java index f72b0f94b1..c4a6e4b5af 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Link.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Link.java @@ -123,7 +123,7 @@ public class Link extends BaseNamedResource { @Override public Link build() { - return new Link(href, name, type, rel); + return new Link(href, type, name, rel); } public Builder fromLink(Link in) { diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Links.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Links.java index f016c873aa..f3b41f82b3 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Links.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Links.java @@ -25,6 +25,8 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Wraps individual Link elements. * Needed because parsing is done with JAXB and it does not handle Generic collections @@ -32,36 +34,75 @@ import java.util.Set; */ public class Links { - private LinkedHashSet links = Sets.newLinkedHashSet(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } - @XmlElement(name = "Link") - public void setLink(Link link) { - this.links.add(link); - } + public Builder toBuilder() { + return new Builder().fromLinks(this); + } - public Set getLinks() { - return Collections.unmodifiableSet(links); - } + public static class Builder { - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + private Set links = Sets.newLinkedHashSet(); - Links links1 = (Links) o; + /** + * @see Links#getLinks + */ + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } - if (!links.equals(links1.links)) return false; + public Builder addLink(Link link) { + links.add(checkNotNull(link,"link")); + return this; + } - return true; - } + public Links build() { + return new Links(links); + } - @Override - public int hashCode() { - return links.hashCode(); - } + public Builder fromLinks(Links in) { + return links(in.getLinks()); + } + } - public String toString() { - return "["+ links.toString()+"]"; - } + @XmlElement(name = "Link") + private LinkedHashSet links = Sets.newLinkedHashSet(); + + private Links() { + //For JAXB + } + + private Links(Set links) { + this.links = Sets.newLinkedHashSet(links); + } + + public Set getLinks() { + return Collections.unmodifiableSet(links); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Links links1 = (Links) o; + + if (!links.equals(links1.links)) return false; + + return true; + } + + @Override + public int hashCode() { + return links.hashCode(); + } + + public String toString() { + return "["+ links.toString()+"]"; + } } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java index affdb76981..5746011698 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java @@ -62,7 +62,7 @@ public class VirtualMachine extends BaseNamedResource { public static class Builder extends BaseNamedResource.Builder { //TODO There are some more fields - private Links links = new Links(); + private Links links = Links.builder().build(); private Actions actions = Actions.builder().build(); private Tasks tasks = new Tasks(); private String description; @@ -81,8 +81,7 @@ public class VirtualMachine extends BaseNamedResource { * @see VirtualMachine#getLinks */ public Builder links(Set links) { - checkNotNull(links,"links"); - for(Link link:links) this.links.setLink(link); + this.links = Links.builder().links(checkNotNull(links,"links")).build(); return this; } @@ -269,7 +268,7 @@ public class VirtualMachine extends BaseNamedResource { } @XmlElement(name = "Links", required = true) - private Links links = new Links(); + private Links links = Links.builder().build(); @XmlElement(name = "Tasks", required = true) private Tasks tasks = new Tasks(); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/LinksTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/LinksTest.java new file mode 100644 index 0000000000..72eb78bd09 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/LinksTest.java @@ -0,0 +1,58 @@ +/** + * 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.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Set; + +import static org.jclouds.tmrk.enterprisecloud.domain.Link.Relationship; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "LinksTest") +public class LinksTest { + + private Link link; + private Links links; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + link = Link.builder().href(new URI("/1")).name("my link").type("test link").rel(Relationship.FIRST).build(); + links = Links.builder().addLink(link).build(); + + } + + @Test + public void testAddAction() throws URISyntaxException { + Link link2 = Link.builder().href(new URI("/2")).name("my link 2").type("test link").rel(Relationship.LAST).build(); + Links twoLinks = links.toBuilder().addLink(link2).build(); + Set linkSet = twoLinks.getLinks(); + + assertEquals(2, linkSet.size()); + assertTrue(linkSet.contains(link)); + assertTrue(linkSet.contains(link2)); + } +} From 7feefaff9e232fb5950a4ce7f1ea3bdbf4756e3a Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 17:15:40 +0000 Subject: [PATCH 3/7] Issue 695: Added Builder+Test for Nics --- .../hardware/HardwareConfiguration.java | 2 +- .../enterprisecloud/domain/network/Nics.java | 90 ++++++++++++++----- .../domain/network/NicsTest.java | 58 ++++++++++++ 3 files changed, 126 insertions(+), 24 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/network/NicsTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java index e0ddd271d8..2d99b5a9a8 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java @@ -163,7 +163,7 @@ public class HardwareConfiguration extends BaseResource { private Disks virtualDisks = Disks.builder().build(); @XmlElement(name = "Nics", required = false) - private Nics virtualNics = new Nics(); + private Nics virtualNics = Nics.builder().build(); public HardwareConfiguration(Set actions, int processorCount, @Nullable Memory memory, Set virtualDisks, Set virtualNics) { this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build(); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java index eb11a8f34b..584a535888 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java @@ -25,6 +25,8 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Wraps individual VirtualNic elements. * Needed because parsing is done with JAXB and it does not handle Generic collections @@ -33,36 +35,78 @@ import java.util.Set; */ public class Nics { - private LinkedHashSet nics = Sets.newLinkedHashSet(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } - @XmlElement(name = "Nic") - public void setVirtualNic(VirtualNic nic) { - this.nics.add(nic); - } + public Builder toBuilder() { + return new Builder().fromNics(this); + } - public Set getVirtualNics() { - return Collections.unmodifiableSet(nics); - } + public static class Builder { - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + private Set nics = Sets.newLinkedHashSet(); - Nics nics1 = (Nics) o; + /** + * @see Nics#getVirtualNics() + */ + public Builder nics(Set nics) { + this.nics = Sets.newLinkedHashSet(checkNotNull(nics, "nics")); + return this; + } - if (!nics.equals(nics1.nics)) return false; + public Builder addVirtualNic(VirtualNic nic) { + nics.add(checkNotNull(nic,"nic")); + return this; + } - return true; - } + public Nics build() { + return new Nics(nics); + } - @Override - public int hashCode() { - return nics.hashCode(); - } + public Builder fromNics(Nics in) { + return nics(in.getVirtualNics()); + } + } - public String toString() { - return "["+ nics.toString()+"]"; - } + private Nics() { + //For JAXB and builder use + } + private Nics(Set nics) { + this.nics = Sets.newLinkedHashSet(nics); + } + + private LinkedHashSet nics = Sets.newLinkedHashSet(); + + @XmlElement(name = "Nic") + public void setVirtualNic(VirtualNic nic) { + this.nics.add(nic); + } + + public Set getVirtualNics() { + return Collections.unmodifiableSet(nics); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Nics nics1 = (Nics) o; + + if (!nics.equals(nics1.nics)) return false; + + return true; + } + + @Override + public int hashCode() { + return nics.hashCode(); + } + + public String toString() { + return "["+ nics.toString()+"]"; + } } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/network/NicsTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/network/NicsTest.java new file mode 100644 index 0000000000..23319de659 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/network/NicsTest.java @@ -0,0 +1,58 @@ +/** + * 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.network; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "NicsTest") +public class NicsTest { + + private NetworkReference networkReference; + private VirtualNic nic; + private Nics nics; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + networkReference = NetworkReference.builder().href(new URI("/netref")).type("a network ref").name("my network ref").build(); + nic = VirtualNic.builder().macAddress("aa:bb").name("my nic").network(networkReference).unitNumber(1).build(); + nics = Nics.builder().addVirtualNic(nic).build(); + } + + @Test + public void testAddDisk() throws URISyntaxException { + VirtualNic nic2 = VirtualNic.builder().macAddress("aa:cc").name("my nic 2").network(networkReference).unitNumber(2).build(); + Nics twoNics = nics.toBuilder().addVirtualNic(nic2).build(); + Set nicSet = twoNics.getVirtualNics(); + + assertEquals(2, nicSet.size()); + assertTrue(nicSet.contains(nic)); + assertTrue(nicSet.contains(nic2)); + } +} From a1c0041650b0ee2deff33a8018714b6a72e9b4cb Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 17:35:21 +0000 Subject: [PATCH 4/7] Issue 695: Removed setter and put annotation on field --- .../domain/hardware/HardwareConfiguration.java | 3 +-- .../jclouds/tmrk/enterprisecloud/domain/network/Nics.java | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java index 2d99b5a9a8..4bf0c2a196 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java @@ -168,8 +168,7 @@ public class HardwareConfiguration extends BaseResource { public HardwareConfiguration(Set actions, int processorCount, @Nullable Memory memory, Set virtualDisks, Set virtualNics) { this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build(); this.virtualDisks = Disks.builder().disks(checkNotNull(virtualDisks,"virtualDisks")).build(); - for( VirtualNic virtualNic: checkNotNull(virtualNics, "virtualNics")) this.virtualNics.setVirtualNic(virtualNic); - + this.virtualNics = Nics.builder().nics(checkNotNull(virtualNics, "virtualNics")).build(); this.processorCount = processorCount; this.memory = memory; } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java index 584a535888..eed23d9221 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java @@ -78,12 +78,8 @@ public class Nics { this.nics = Sets.newLinkedHashSet(nics); } - private LinkedHashSet nics = Sets.newLinkedHashSet(); - @XmlElement(name = "Nic") - public void setVirtualNic(VirtualNic nic) { - this.nics.add(nic); - } + private LinkedHashSet nics = Sets.newLinkedHashSet(); public Set getVirtualNics() { return Collections.unmodifiableSet(nics); From c67072f5b57ef0c68fd5a6a2d41942c96438e2a3 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 17:48:19 +0000 Subject: [PATCH 5/7] Issue 695: Added builder for Tasks, test and removed setter --- .../tmrk/enterprisecloud/domain/Tasks.java | 90 +++++++++++++------ .../domain/vm/VirtualMachine.java | 8 +- .../enterprisecloud/domain/TasksTest.java | 89 ++++++++++++++++++ 3 files changed, 157 insertions(+), 30 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/TasksTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Tasks.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Tasks.java index 8c411d3701..f3d5224fe6 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Tasks.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Tasks.java @@ -36,37 +36,77 @@ import static com.google.common.base.Preconditions.checkNotNull; */ @XmlRootElement(name = "Tasks") public class Tasks { - //TODO: There is a total count field - private LinkedHashSet tasks = Sets.newLinkedHashSet(); - @XmlElement(name = "Task") - public void setTask(Task task) { - checkNotNull(task,"task"); - tasks.add(task); - } + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } - public Set getTasks() { - return Collections.unmodifiableSet(tasks); - } + public Builder toBuilder() { + return new Builder().fromTasks(this); + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public static class Builder { - Tasks tasks1 = (Tasks) o; + private Set tasks = Sets.newLinkedHashSet(); - if (!tasks.equals(tasks1.tasks)) return false; + /** + * @see Tasks#getTasks + */ + public Builder tasks(Set tasks) { + this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); + return this; + } - return true; - } + public Builder addTask(Task task) { + tasks.add(checkNotNull(task,"task")); + return this; + } - @Override - public int hashCode() { - return tasks.hashCode(); - } + public Tasks build() { + return new Tasks(tasks); + } - public String toString() { - return "["+tasks.toString()+"]"; - } + public Builder fromTasks(Tasks in) { + return tasks(in.getTasks()); + } + } + + private Tasks() { + //For JAXB and builder use + } + + private Tasks(Set tasks) { + this.tasks = Sets.newLinkedHashSet(tasks); + } + + //TODO: There is a total count field + + @XmlElement(name = "Task") + private LinkedHashSet tasks = Sets.newLinkedHashSet(); + + public Set getTasks() { + return Collections.unmodifiableSet(tasks); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Tasks tasks1 = (Tasks) o; + + if (!tasks.equals(tasks1.tasks)) return false; + + return true; + } + + @Override + public int hashCode() { + return tasks.hashCode(); + } + + public String toString() { + return "["+tasks.toString()+"]"; + } } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java index 5746011698..1d66ba870c 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java @@ -64,7 +64,7 @@ public class VirtualMachine extends BaseNamedResource { //TODO There are some more fields private Links links = Links.builder().build(); private Actions actions = Actions.builder().build(); - private Tasks tasks = new Tasks(); + private Tasks tasks = Tasks.builder().build(); private String description; private VirtualMachineStatus status; @@ -98,12 +98,10 @@ public class VirtualMachine extends BaseNamedResource { * @see VirtualMachine#getTasks */ public Builder tasks(Set tasks) { - checkNotNull(tasks,"tasks"); - for(Task task: tasks) this.tasks.setTask(task); + this.tasks = Tasks.builder().tasks(checkNotNull(tasks,"tasks")).build(); return this; } - /** * @see VirtualMachine#getDescription */ @@ -271,7 +269,7 @@ public class VirtualMachine extends BaseNamedResource { private Links links = Links.builder().build(); @XmlElement(name = "Tasks", required = true) - private Tasks tasks = new Tasks(); + private Tasks tasks = Tasks.builder().build(); @XmlElement(name = "Actions", required = true) private Actions actions = Actions.builder().build(); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/TasksTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/TasksTest.java new file mode 100644 index 0000000000..12b393fb45 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/TasksTest.java @@ -0,0 +1,89 @@ +/** + * 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.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Date; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "TasksTest") +public class TasksTest { + + private Task task; + private Tasks tasks; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + task = Task + .builder() + .href(URI.create("/tasks/1002")) + .type("application/vnd.tmrk.cloud.task") + .operation("test task") + .status(Task.Status.ERROR) + .impactedItem( + NamedResource.builder().href(URI.create("/item/1")).name("sample item 1") + .type("application/vnd.tmrk.cloud.nodeService").build()) + .startTime(new Date()) + .completedTime(new Date()) + .notes("Some notes about the operation.") + .errorMessage("sample error message 1 here") + .initiatedBy( + NamedResource.builder().href(URI.create("/users/1")).name("User 1") + .type("application/vnd.tmrk.cloud.admin.user").build()).build(); + + tasks = Tasks.builder().addTask(task).build(); + } + + @Test + public void testAddAction() throws URISyntaxException { + Task task2 = Task + .builder() + .href(URI.create("/tasks/1003")) + .type("application/vnd.tmrk.cloud.task") + .operation("test task 2") + .status(Task.Status.ERROR) + .impactedItem( + NamedResource.builder().href(URI.create("/item/2")).name("sample item 2") + .type("application/vnd.tmrk.cloud.nodeService").build()) + .startTime(new Date()) + .completedTime(new Date()) + .notes("Some notes about the operation.") + .errorMessage("sample error message 2 here") + .initiatedBy( + NamedResource.builder().href(URI.create("/users/2")).name("User 2") + .type("application/vnd.tmrk.cloud.admin.user").build()).build(); + + Tasks twoTasks = tasks.toBuilder().addTask(task2).build(); + Set taskSet = twoTasks.getTasks(); + + assertEquals(2,taskSet.size()); + assertTrue(taskSet.contains(task)); + assertTrue(taskSet.contains(task2)); + } +} From 0cada01d5eb6a4edde3528b642762429bf46b3b7 Mon Sep 17 00:00:00 2001 From: Jason King Date: Tue, 22 Nov 2011 09:44:55 +0000 Subject: [PATCH 6/7] Issue 695: Moved DisksTest package into correct parent --- .../tmrk/enterprisecloud/{ => domain}/hardware/DisksTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/{ => domain}/hardware/DisksTest.java (91%) diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DisksTest.java similarity index 91% rename from sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java rename to sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DisksTest.java index 54ce6db170..a9cabd7d95 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/hardware/DisksTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/DisksTest.java @@ -16,11 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.hardware; +package org.jclouds.tmrk.enterprisecloud.domain.hardware; import org.jclouds.tmrk.enterprisecloud.domain.Size; -import org.jclouds.tmrk.enterprisecloud.domain.hardware.Disks; -import org.jclouds.tmrk.enterprisecloud.domain.hardware.VirtualDisk; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; From f823a4d9de139f6a00a9ca7cdf08da6455e5b69c Mon Sep 17 00:00:00 2001 From: Jason King Date: Tue, 22 Nov 2011 10:08:55 +0000 Subject: [PATCH 7/7] Issue 695: Added VirtalMachines builder+test --- .../domain/vm/VirtualMachine.java | 2 +- .../domain/vm/VirtualMachines.java | 87 ++++++++++++++----- .../domain/vm/VirtualMachinesTest.java | 80 +++++++++++++++++ 3 files changed, 145 insertions(+), 24 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachinesTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java index 1d66ba870c..0d3ec7d5e5 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java @@ -313,6 +313,7 @@ public class VirtualMachine extends BaseNamedResource { this.tasks = checkNotNull(tasks, "tasks"); this.actions = checkNotNull(actions, "actions"); this.status = checkNotNull(status, "status"); + this.ipAddresses = checkNotNull(ipAddresses, "ipAddresses"); this.layout = layout; this.poweredOn = poweredOn; @@ -321,7 +322,6 @@ public class VirtualMachine extends BaseNamedResource { this.customizationPending = customizationPending; this.operatingSystem = operatingSystem; this.hardwareConfiguation = hardwareConfiguration; - this.ipAddresses = checkNotNull(ipAddresses, "ipAddresses"); } protected VirtualMachine() { diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java index 09a12eefd3..e687182747 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java @@ -26,6 +26,8 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Wraps individual VirtualMachine elements. * Needed because parsing is done with JAXB and it does not handle Generic collections @@ -35,35 +37,74 @@ import java.util.Set; @XmlRootElement(name="VirtualMachines") public class VirtualMachines { - private LinkedHashSet virtualMachines = Sets.newLinkedHashSet(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } - @XmlElement(name = "VirtualMachine") - void setVirtualMachine(VirtualMachine nic) { - this.virtualMachines.add(nic); - } + public Builder toBuilder() { + return new Builder().fromVirtualMachines(this); + } - public Set getVirtualMachines() { - return Collections.unmodifiableSet(virtualMachines); - } + public static class Builder { - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + private Set virtualMachines = Sets.newLinkedHashSet(); - VirtualMachines vms1 = (VirtualMachines) o; + /** + * @see VirtualMachines#getVirtualMachines + */ + public Builder virtualMachines(Set virtualMachines) { + this.virtualMachines = Sets.newLinkedHashSet(checkNotNull(virtualMachines, "virtualMachines")); + return this; + } - if (!virtualMachines.equals(vms1.virtualMachines)) return false; + public Builder addVirtualMachine(VirtualMachine virtualMachine) { + virtualMachines.add(checkNotNull(virtualMachine,"virtualMachine")); + return this; + } - return true; - } + public VirtualMachines build() { + return new VirtualMachines(virtualMachines); + } - @Override - public int hashCode() { - return virtualMachines.hashCode(); - } + public Builder fromVirtualMachines(VirtualMachines in) { + return virtualMachines(in.getVirtualMachines()); + } + } - public String toString() { - return "["+ virtualMachines.toString()+"]"; - } + private VirtualMachines() { + //For JAXB and builder use + } + + private VirtualMachines(Set virtualMachines) { + this.virtualMachines = Sets.newLinkedHashSet(virtualMachines); + } + + @XmlElement(name = "VirtualMachine") + private LinkedHashSet virtualMachines = Sets.newLinkedHashSet(); + + public Set getVirtualMachines() { + return Collections.unmodifiableSet(virtualMachines); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + VirtualMachines vms1 = (VirtualMachines) o; + + if (!virtualMachines.equals(vms1.virtualMachines)) return false; + + return true; + } + + @Override + public int hashCode() { + return virtualMachines.hashCode(); + } + + public String toString() { + return "["+ virtualMachines.toString()+"]"; + } } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachinesTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachinesTest.java new file mode 100644 index 0000000000..8556f50602 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachinesTest.java @@ -0,0 +1,80 @@ +/** + * 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.vm; + +import org.jclouds.tmrk.enterprisecloud.domain.Actions; +import org.jclouds.tmrk.enterprisecloud.domain.Links; +import org.jclouds.tmrk.enterprisecloud.domain.Tasks; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "ActionsTest") +public class VirtualMachinesTest { + + private VirtualMachine virtualMachine; + private VirtualMachines virtualMachines; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + virtualMachine = VirtualMachine.builder() + .description("This is a test VM") + .name("Test VM") + .href(new URI("/test")) + .type("Test VM") + .actions(Actions.builder().build().getActions()) + .links(Links.builder().build().getLinks()) + .tasks(Tasks.builder().build().getTasks()) + .status(VirtualMachine.VirtualMachineStatus.NOT_DEPLOYED) + .ipAddresses(new VirtualMachineIpAddresses()) + .build(); + + virtualMachines = VirtualMachines.builder().addVirtualMachine(virtualMachine).build(); + } + + @Test + public void testAddAction() throws URISyntaxException { + VirtualMachine virtualMachine2 = VirtualMachine.builder() + .description("This is a test VM 2") + .name("Test VM 2") + .href(new URI("/test/2")) + .type("Test VM 2") + .actions(Actions.builder().build().getActions()) + .links(Links.builder().build().getLinks()) + .tasks(Tasks.builder().build().getTasks()) + .status(VirtualMachine.VirtualMachineStatus.NOT_DEPLOYED) + .ipAddresses(new VirtualMachineIpAddresses()) + .build(); + + VirtualMachines twoVirtualMachines = virtualMachines.toBuilder().addVirtualMachine(virtualMachine2).build(); + Set virtualMachineSet = twoVirtualMachines.getVirtualMachines(); + assertEquals(2, virtualMachineSet.size()); + assertTrue(virtualMachineSet.contains(virtualMachine)); + assertTrue(virtualMachineSet.contains(virtualMachine2)); + } +}