You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2013/07/02 18:28:50 UTC
[3/8] JCLOUDS-156: Cleanup Abiquo provider
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
index 7bc99a1..2fd033c 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java
@@ -73,11 +73,6 @@ public class ListVirtualDatacenters implements ListRootEntities<VirtualDatacente
return execute(userExecutor);
}
- @Override
- public Iterable<VirtualDatacenter> execute(final Predicate<VirtualDatacenter> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<VirtualDatacenter> execute(final VirtualDatacenterOptions virtualDatacenterOptions) {
VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions);
return wrap(context, VirtualDatacenter.class, result.getCollection());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
index 50cd9aa..aeb8ac0 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java
@@ -79,11 +79,6 @@ public class ListVirtualMachines implements ListRootEntities<VirtualMachine> {
return execute(userExecutor);
}
- @Override
- public Iterable<VirtualMachine> execute(final Predicate<VirtualMachine> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<VirtualMachine> execute(ListeningExecutorService executor) {
return execute(executor, VirtualMachineOptions.builder().disablePagination().build());
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
index 79b5ada..d82d3ad 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java
@@ -75,12 +75,6 @@ public class ListVirtualMachineTemplates implements ListEntities<VirtualMachineT
return execute(userExecutor, parent);
}
- @Override
- public Iterable<VirtualMachineTemplate> execute(final Enterprise parent,
- final Predicate<VirtualMachineTemplate> selector) {
- return execute(userExecutor, parent, selector);
- }
-
public Iterable<VirtualMachineTemplate> execute(ListeningExecutorService executor, final Enterprise parent) {
// Find virtual machine templates in concurrent requests
Iterable<Datacenter> dcs = parent.listAllowedDatacenters();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java b/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
index f4656e6..df98a03 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java
@@ -77,11 +77,6 @@ public class ListMachines implements ListRootEntities<Machine> {
return execute(userExecutor);
}
- @Override
- public Iterable<Machine> execute(final Predicate<Machine> selector) {
- return execute(userExecutor, selector);
- }
-
public Iterable<Machine> execute(ListeningExecutorService executor) {
// Find machines in concurrent requests
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
index e7a51c2..59601cd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java
@@ -51,7 +51,6 @@ public class AbiquoDelegateApiTest extends BaseAbiquoApiTest<AbiquoApi> {
assertNotNull(syncApi.getCloudApi());
assertNotNull(syncApi.getVirtualMachineTemplateApi());
assertNotNull(syncApi.getTaskApi());
- assertNotNull(syncApi.getPricingApi());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java b/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
deleted file mode 100644
index 4992c6b..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.binders.infrastructure.ucs;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.LogicServerDto;
-
-/**
- * Unit tests for the {@link BindLogicServerParameters} binder.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "unit", testName = "BindLogicServerParametersTest")
-public class BindLogicServerParametersTest {
- @Test(expectedExceptions = NullPointerException.class)
- public void testInvalidNullInput() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testInvalidTypeInput() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, new Object());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testBindLogicServerWithEmptyName() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- LogicServerDto dto = new LogicServerDto();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, dto);
- }
-
- public void testBindLogicServer() {
- BindLogicServerParameters binder = new BindLogicServerParameters();
- LogicServerDto dto = new LogicServerDto();
- dto.setName("name");
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- HttpRequest newRequest = binder.bindToRequest(request, dto);
- assertEquals(newRequest.getRequestLine(), "GET http://localhost?lsName=name HTTP/1.1");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java b/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
deleted file mode 100644
index 7735b48..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.binders.infrastructure.ucs;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.OrganizationDto;
-
-/**
- * Unit tests for the {@link BindOrganizationParameters} binder.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "unit", testName = "BindOrganizationParametersTest")
-public class BindOrganizationParametersTest {
- @Test(expectedExceptions = NullPointerException.class)
- public void testInvalidNullInput() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testInvalidTypeInput() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, new Object());
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testBindLogicServerWithEmptyName() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- OrganizationDto dto = new OrganizationDto();
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- binder.bindToRequest(request, dto);
- }
-
- public void testBindLogicServer() {
- BindOrganizationParameters binder = new BindOrganizationParameters();
- OrganizationDto dto = new OrganizationDto();
- dto.setDn("org");
- HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
- HttpRequest newRequest = binder.bindToRequest(request, dto);
- assertEquals(newRequest.getRequestLine(), "GET http://localhost?org=org HTTP/1.1");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
index 82df566..2c46e51 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java
@@ -21,12 +21,9 @@ import static org.jclouds.abiquo.domain.DomainUtils.link;
import com.abiquo.model.enumerator.RemoteServiceType;
import com.abiquo.model.rest.RESTLink;
import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.LogicServerDto;
import com.abiquo.server.core.infrastructure.MachineDto;
-import com.abiquo.server.core.infrastructure.OrganizationDto;
import com.abiquo.server.core.infrastructure.RackDto;
import com.abiquo.server.core.infrastructure.RemoteServiceDto;
-import com.abiquo.server.core.infrastructure.UcsRackDto;
import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto;
import com.abiquo.server.core.infrastructure.storage.StoragePoolDto;
import com.abiquo.server.core.infrastructure.storage.TierDto;
@@ -56,18 +53,6 @@ public class InfrastructureResources {
return rack;
}
- public static UcsRackDto managedRackPost() {
- UcsRackDto rack = new UcsRackDto();
- rack.setName("Aloha");
- rack.setShortDescription("A hawaian rack");
- rack.setHaEnabled(false);
- rack.setVlanIdMin(6);
- rack.setVlanIdMax(3024);
- rack.setVlanPerVdcReserved(6);
- rack.setNrsq(80);
- return rack;
- }
-
public static MachineDto machinePost() {
MachineDto machine = new MachineDto();
machine.setName("Kamehameha");
@@ -136,46 +121,6 @@ public class InfrastructureResources {
return rack;
}
- public static UcsRackDto managedRackPut() {
- UcsRackDto rack = managedRackPost();
- rack.setId(1);
- rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1"));
- rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1"));
- rack.addLink(new RESTLink("fsm", "http://localhost/api/admin/datacenters/1/racks/1/fsm"));
- rack.addLink(new RESTLink("logicservers", "http://localhost/api/admin/datacenters/1/racks/1/logicservers"));
- rack.addLink(new RESTLink("ls-templates", "http://localhost/api/admin/datacenters/1/racks/1/lstemplates"));
- rack.addLink(new RESTLink("organizations", "http://localhost/api/admin/datacenters/1/racks/1/organizations"));
- rack.addLink(new RESTLink("ls-associate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate"));
- rack.addLink(new RESTLink("ls-associateclone",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone"));
- rack.addLink(new RESTLink("ls-associatetemplate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate"));
- rack.addLink(new RESTLink("ls-clone", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone"));
- rack.addLink(new RESTLink("ls-delete", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete"));
- rack.addLink(new RESTLink("ls-dissociate",
- "http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate"));
- return rack;
- }
-
- public static LogicServerDto logicServerPut() {
- LogicServerDto logicServer = new LogicServerDto();
- logicServer.setName("server");
- logicServer.setAssociated("associated");
- logicServer.setType("instance");
-
- return logicServer;
- }
-
- public static OrganizationDto organizationPut() {
- OrganizationDto org = new OrganizationDto();
- org.setName("org");
- org.setDn("org-root/org-Finance");
- org.setLevel("1");
-
- return org;
- }
-
public static TierDto tierPut() {
TierDto tier = new TierDto();
tier.setId(1);
@@ -269,20 +214,6 @@ public class InfrastructureResources {
return buffer.toString();
}
- public static String managedRackPostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<ucsrack>");
- buffer.append("<haEnabled>false</haEnabled>");
- buffer.append("<name>Aloha</name>");
- buffer.append("<nrsq>80</nrsq>");
- buffer.append("<shortDescription>A hawaian rack</shortDescription>");
- buffer.append("<vlanIdMax>3024</vlanIdMax>");
- buffer.append("<vlanIdMin>6</vlanIdMin>");
- buffer.append("<vlanPerVdcReserved>6</vlanPerVdcReserved>");
- buffer.append("</ucsrack>");
- return buffer.toString();
- }
-
public static String storagePoolPostPayload() {
StringBuilder buffer = new StringBuilder();
buffer.append("<storagePool>");
@@ -402,33 +333,6 @@ public class InfrastructureResources {
return buffer.toString();
}
- public static String managedRackPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<ucsrack>");
- buffer.append(link("/admin/datacenters/1", "datacenter"));
- buffer.append(link("/admin/datacenters/1/racks/1", "edit"));
- buffer.append(link("/admin/datacenters/1/racks/1/fsm", "fsm"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers", "logicservers"));
- buffer.append(link("/admin/datacenters/1/racks/1/lstemplates", "ls-templates"));
- buffer.append(link("/admin/datacenters/1/racks/1/organizations", "organizations"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associate", "ls-associate"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/assocclone", "ls-associateclone"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associatetemplate", "ls-associatetemplate"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/clone", "ls-clone"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/delete", "ls-delete"));
- buffer.append(link("/admin/datacenters/1/racks/1/logicservers/dissociate", "ls-dissociate"));
- buffer.append("<haEnabled>false</haEnabled>");
- buffer.append("<id>1</id>");
- buffer.append("<name>Aloha</name>");
- buffer.append("<nrsq>80</nrsq>");
- buffer.append("<shortDescription>A hawaian rack</shortDescription>");
- buffer.append("<vlanIdMax>3024</vlanIdMax>");
- buffer.append("<vlanIdMin>6</vlanIdMin>");
- buffer.append("<vlanPerVdcReserved>6</vlanPerVdcReserved>");
- buffer.append("</ucsrack>");
- return buffer.toString();
- }
-
public static String storageDevicePutPayload() {
StringBuilder buffer = new StringBuilder();
buffer.append("<device>");
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
deleted file mode 100644
index f8fe258..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain;
-
-import static org.jclouds.abiquo.domain.DomainUtils.link;
-
-import java.math.BigDecimal;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
-import com.abiquo.server.core.pricing.CostCodeCurrencyDto;
-import com.abiquo.server.core.pricing.CostCodeDto;
-import com.abiquo.server.core.pricing.CurrencyDto;
-import com.abiquo.server.core.pricing.PricingCostCodeDto;
-import com.abiquo.server.core.pricing.PricingTemplateDto;
-import com.abiquo.server.core.pricing.PricingTierDto;
-
-/**
- * Enterprise domain utilities.
- *
- * @author Ignasi Barrera
- * @author Susana Acedo
- */
-public class PricingResources {
-
- public static CurrencyDto currencyPost() {
- CurrencyDto currency = new CurrencyDto();
- currency.setName("yuan");
- currency.setSymbol("DUMMY");
- currency.setDigits(3);
- return currency;
- }
-
- public static CurrencyDto currencyPut() {
- CurrencyDto currency = new CurrencyDto();
- currency.setName("yuan");
- currency.setSymbol("DUMMY");
- currency.setDigits(3);
- currency.setId(1);
- currency.addLink(new RESTLink("edit", "http://localhost/api/config/currencies/1"));
- return currency;
- }
-
- public static String currencyPostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<currency>");
- buffer.append("<symbol>DUMMY</symbol>");
- buffer.append("<digits>3</digits>");
- buffer.append("<name>yuan</name>");
- buffer.append("</currency>");
- return buffer.toString();
- }
-
- public static String currencyPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<currency>");
- buffer.append(link("/config/currencies/1", "edit"));
- buffer.append("<symbol>DUMMY</symbol>");
- buffer.append("<digits>3</digits>");
- buffer.append("<id>1</id>");
- buffer.append("<name>yuan</name>");
- buffer.append("</currency>");
- return buffer.toString();
- }
-
- public static Object costcodePost() {
- CostCodeDto costcode = new CostCodeDto();
- costcode.setName("cost code");
- costcode.setDescription("description");
- return costcode;
- }
-
- public static Object costcodePut() {
- CostCodeDto costcode = new CostCodeDto();
- costcode.setName("cost code");
- costcode.setDescription("description");
- costcode.setId(1);
- costcode.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1"));
- return costcode;
- }
-
- public static String costcodePostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCode>");
- buffer.append("<name>cost code</name>");
- buffer.append("<description>description</description>");
- buffer.append("</costCode>");
- return buffer.toString();
- }
-
- public static String costcodePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCode>");
- buffer.append(link("/config/costcodes/1", "edit"));
- buffer.append("<description>description</description>");
- buffer.append("<id>1</id>");
- buffer.append("<name>cost code</name>");
- buffer.append("</costCode>");
- return buffer.toString();
- }
-
- public static Object pricingtemplatePost() {
- PricingTemplateDto pricingtemplate = new PricingTemplateDto();
- pricingtemplate.setName("pricing template");
- pricingtemplate.setDescription("pt_description");
- pricingtemplate.setHdGB(new BigDecimal(0));
- pricingtemplate.setStandingChargePeriod(new BigDecimal(0));
- pricingtemplate.setVlan(new BigDecimal(0));
- pricingtemplate.setChargingPeriod(1);
- pricingtemplate.setMinimumChargePeriod(new BigDecimal(0));
- pricingtemplate.setShowChangesBefore(true);
- pricingtemplate.setShowMinimumCharge(false);
- pricingtemplate.setMinimumCharge(2);
- pricingtemplate.setPublicIp(new BigDecimal(0));
- pricingtemplate.setVcpu(new BigDecimal(0));
- pricingtemplate.setMemoryGB(new BigDecimal(0));
- pricingtemplate.setDefaultTemplate(true);
- pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- return pricingtemplate;
- }
-
- public static Object pricingtemplatePut() {
- PricingTemplateDto pricingtemplate = new PricingTemplateDto();
- pricingtemplate.setName("pricing template");
- pricingtemplate.setDescription("pt_description");
- pricingtemplate.setHdGB(new BigDecimal(0));
- pricingtemplate.setStandingChargePeriod(new BigDecimal(0));
- pricingtemplate.setVlan(new BigDecimal(0));
- pricingtemplate.setChargingPeriod(1);
- pricingtemplate.setMinimumChargePeriod(new BigDecimal(0));
- pricingtemplate.setShowChangesBefore(true);
- pricingtemplate.setShowMinimumCharge(false);
- pricingtemplate.setMinimumCharge(2);
- pricingtemplate.setPublicIp(new BigDecimal(0));
- pricingtemplate.setVcpu(new BigDecimal(0));
- pricingtemplate.setMemoryGB(new BigDecimal(0));
- pricingtemplate.setDefaultTemplate(true);
- pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- pricingtemplate.setId(1);
- pricingtemplate.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1"));
- return pricingtemplate;
- }
-
- public static String pricingtemplatePostPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTemplate>");
- buffer.append("<name>pricing template</name>");
- buffer.append("<description>pt_description</description>");
- buffer.append("<hdGB>0</hdGB>");
- buffer.append("<standingChargePeriod>0</standingChargePeriod>");
- buffer.append("<vlan>0</vlan>");
- buffer.append("<chargingPeriod>1</chargingPeriod>");
- buffer.append("<minimumChargePeriod>0</minimumChargePeriod>");
- buffer.append("<showChangesBefore>true</showChangesBefore>");
- buffer.append("<showMinimumCharge>false</showMinimumCharge>");
- buffer.append("<minimumCharge>2</minimumCharge>");
- buffer.append("<memoryGB>0</memoryGB>");
- buffer.append("<publicIp>0</publicIp>");
- buffer.append("<vcpu>0</vcpu>");
- buffer.append("<memoryMB>0</memoryMB>");
- buffer.append("<defaultTemplate>true</defaultTemplate>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("</pricingTemplate>");
- return buffer.toString();
- }
-
- public static String pricingtemplatePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTemplate>");
- buffer.append("<name>pricing template</name>");
- buffer.append("<description>pt_description</description>");
- buffer.append("<hdGB>0</hdGB>");
- buffer.append("<standingChargePeriod>0</standingChargePeriod>");
- buffer.append("<vlan>0</vlan>");
- buffer.append("<chargingPeriod>1</chargingPeriod>");
- buffer.append("<minimumChargePeriod>0</minimumChargePeriod>");
- buffer.append("<showChangesBefore>true</showChangesBefore>");
- buffer.append("<showMinimumCharge>false</showMinimumCharge>");
- buffer.append("<minimumCharge>2</minimumCharge>");
- buffer.append("<memoryGB>0</memoryGB>");
- buffer.append("<publicIp>0</publicIp>");
- buffer.append("<vcpu>0</vcpu>");
- buffer.append("<memoryMB>0</memoryMB>");
- buffer.append("<defaultTemplate>true</defaultTemplate>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1", "edit"));
- buffer.append("</pricingTemplate>");
- return buffer.toString();
- }
-
- public static Object costcodecurrencyPut() {
- CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto();
- costcodecurrency.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1/currencies"));
- costcodecurrency.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1"));
- costcodecurrency.setPrice(new BigDecimal("300"));
- CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto();
- costcodecurrencies.add(costcodecurrency);
- return costcodecurrencies;
- }
-
- public static String costcodecurrencyPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<costCodeCurrencies>");
- buffer.append("<costCodeCurrency>");
- buffer.append("<price>300</price>");
- buffer.append("<link href='http://localhost/api/config/costcodes/1/currencies' rel='edit'/>");
- buffer.append("<link href='http://localhost/api/config/currencies/1' rel='currency'/>");
- buffer.append("</costCodeCurrency>");
-
- buffer.append("</costCodeCurrencies>");
- return buffer.toString();
- }
-
- public static Object pricingCostcodePut() {
- PricingCostCodeDto pricingcostcode = new PricingCostCodeDto();
- pricingcostcode.setId(1);
- pricingcostcode.setPrice(new BigDecimal("400"));
- pricingcostcode.addLink(new RESTLink("costcode", "http://localhost/api/config/costcodes/1"));
- pricingcostcode.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1"));
- pricingcostcode.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/costcodes/1"));
- return pricingcostcode;
- }
-
- public static String pricingCostCodePutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingCostCode>");
- buffer.append("<link href='http://localhost/api/config/costcodes/1' rel='costcode'/>");
- buffer.append("<link href='http://localhost/api/config/pricingtemplates/1' rel='pricingtemplate'/>");
- buffer.append("<price>400</price>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1/costcodes/1", "edit"));
- buffer.append("</pricingCostCode>");
- return buffer.toString();
- }
-
- public static Object pricingTierPut() {
- PricingTierDto pricingtier = new PricingTierDto();
- pricingtier.setId(1);
- pricingtier.setPrice(new BigDecimal("600"));
- pricingtier.addLink(new RESTLink("tier", "http://localhost/api/admin/datacenters/1/storage/tiers/2"));
- pricingtier.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1"));
- pricingtier.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/tiers/2"));
- return pricingtier;
- }
-
- public static String pricingTierPutPayload() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("<pricingTier>");
- buffer.append("<link href='http://localhost/api/admin/datacenters/1/storage/tiers/2' rel='tier'/>");
- buffer.append("<link href='http://localhost/api/config/pricingtemplates/1' rel='pricingtemplate'/>");
- buffer.append("<price>600</price>");
- buffer.append("<id>1</id>");
- buffer.append(link("/config/pricingtemplates/1/tiers/2", "edit"));
- buffer.append("</pricingTier>");
- return buffer.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
index b99c9cb..38f139a 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java
@@ -16,9 +16,9 @@
*/
package org.jclouds.abiquo.domain.admin;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.util.List;
@@ -30,12 +30,11 @@ import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.domain.enterprise.Role;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PrivilegePredicates;
-import org.jclouds.abiquo.predicates.enterprise.RolePredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.enterprise.PrivilegeDto;
import com.abiquo.server.core.enterprise.RoleDto;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
/**
@@ -73,28 +72,33 @@ public class RoleLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testCreateEnterpriseRole() {
- Role entRole = Role.Builder.fromRole(env.role).build();
+ final Role entRole = Role.Builder.fromRole(env.role).build();
entRole.setName(entRole.getName() + "enterprise");
entRole.setEnterprise(env.enterprise);
entRole.save();
- entRole = env.enterprise.findRole(RolePredicates.name(entRole.getName()));
-
- assertNotNull(entRole);
+ find(env.enterprise.listRoles(), new Predicate<Role>() {
+ @Override
+ public boolean apply(Role input) {
+ return input.getName().equals(entRole.getName());
+ }
+ });
}
public void testAddPrivilege() {
PrivilegeDto dto = env.configApi.getPrivilege(8);
- Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto);
+ final Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto);
List<Privilege> privileges = Lists.newArrayList(env.role.listPrivileges());
privileges.add(privilege);
env.role.setPrivileges(privileges);
-
env.role.update();
- privilege = env.role.findPrivileges(PrivilegePredicates.name(dto.getName()));
-
- assertNotNull(privilege);
+ find(env.role.listPrivileges(), new Predicate<Privilege>() {
+ @Override
+ public boolean apply(Privilege input) {
+ return input.getName().equals(privilege.getName());
+ }
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
index f9856f7..4be19aa 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getLast;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
@@ -27,12 +28,12 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.cloud.VirtualApplianceState;
import com.abiquo.server.core.cloud.VirtualMachineState;
+import com.google.common.base.Predicate;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -109,9 +110,15 @@ public class VirtualApplianceLiveTest extends BaseAbiquoLiveApiTest {
@Test(dependsOnMethods = "testUndeployVirtualAppliance")
public void testDeleteVirtualAppliance() {
+ final String name = vapp.getName();
vapp.delete();
- assertNull(view.getCloudService().findVirtualAppliance(
- VirtualAppliancePredicates.name(PREFIX + "Virtual Appliance Updated")));
+
+ assertNull(find(view.getCloudService().listVirtualAppliances(), new Predicate<VirtualAppliance>() {
+ @Override
+ public boolean apply(VirtualAppliance input) {
+ return input.getName().equals(name);
+ }
+ }, null));
}
private static Ordering<VirtualMachineTemplate> templateBySize() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
index 5f542a0..c6c6fdd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.size;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
@@ -33,12 +34,11 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.network.PublicIp;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.Test;
import com.abiquo.model.enumerator.HypervisorType;
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link VirtualDatacenter} domain class.
@@ -130,15 +130,24 @@ public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testPurchaseIp() {
- PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0);
+ final PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0);
assertNotNull(publicIp);
env.virtualDatacenter.purchasePublicIp(publicIp);
- PublicIp apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(publicIp.getIp()));
- assertNotNull(apiIp);
+ PublicIp apiIp = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIp.getIp());
+ }
+ });
env.virtualDatacenter.releasePublicIp(apiIp);
- apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(publicIp.getIp()));
+ apiIp = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIp.getIp());
+ }
+ }, null);
assertNull(apiIp);
}
@@ -159,16 +168,6 @@ public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
@Test(dependsOnMethods = "testGetAvailableTemplates")
- public void testFindAvailableTemplate() {
- VirtualMachineTemplate templateFound = env.virtualDatacenter
- .findAvailableTemplate(VirtualMachineTemplatePredicates.id(template.getId()));
-
- assertNotNull(template);
- assertNotNull(templateFound);
- assertEquals(templateFound.getId(), template.getId());
- }
-
- @Test(dependsOnMethods = "testGetAvailableTemplates")
public void testGetAvailableTemplate() {
VirtualMachineTemplate templateFound = env.virtualDatacenter.getAvailableTemplate(template.getId());
assertNotNull(templateFound);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
index aaba872..1d2aedd 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getLast;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.jclouds.abiquo.util.Assert.assertHasError;
@@ -34,13 +35,12 @@ import org.jclouds.abiquo.domain.network.Ip;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.features.services.MonitoringService;
import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.abiquo.server.core.cloud.VirtualMachineState;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
@@ -99,8 +99,12 @@ public class VirtualMachineLiveTest extends BaseAbiquoLiveApiTest {
AsyncTask task = vm.update();
assertNull(task);
- VirtualMachine updated = vapp.findVirtualMachine(VirtualMachinePredicates.nameLabel(PREFIX + "VM Kane Updated"));
- assertNotNull(updated);
+ find(vapp.listVirtualMachines(), new Predicate<VirtualMachine>() {
+ @Override
+ public boolean apply(VirtualMachine input) {
+ return input.getNameLabel().equals(PREFIX + "VM Kane Updated");
+ }
+ });
}
@Test(dependsOnMethods = "testUpdateVirtualMachineWhenNotDeployed")
@@ -123,13 +127,19 @@ public class VirtualMachineLiveTest extends BaseAbiquoLiveApiTest {
@Test(dependsOnMethods = "testChangeVirtualMachineState")
public void testReconfigure() {
- Ip<?, ?> ip = getLast(vdc.getDefaultNetwork().listUnusedIps());
+ final Ip<?, ?> ip = getLast(vdc.getDefaultNetwork().listUnusedIps());
AsyncTask task = vm.setNics(Lists.<Ip<?, ?>> newArrayList(ip));
assertNotNull(task);
monitoringService.getVirtualMachineMonitor().awaitState(MAX_WAIT, TimeUnit.MINUTES, VirtualMachineState.OFF, vm);
- assertNotNull(vm.findAttachedNic(IpPredicates.address(ip.getIp())));
+
+ find(vm.listAttachedNics(), new Predicate<Ip<?, ?>>() {
+ @Override
+ public boolean apply(Ip<?, ?> input) {
+ return input.getIp().equals(ip.getIp());
+ }
+ });
}
@Test(dependsOnMethods = "testReconfigure")
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
index baa6aee..c1fc61b 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -36,11 +37,11 @@ import org.jclouds.abiquo.domain.network.UnmanagedIp;
import org.jclouds.abiquo.domain.network.UnmanagedNetwork;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.network.IpPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
/**
@@ -73,9 +74,12 @@ public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTes
publicIpInfrastructure = env.virtualDatacenter.listAvailablePublicIps().get(0);
env.virtualDatacenter.purchasePublicIp(publicIpInfrastructure);
- publicIpCloud = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates
- .<PublicIp> address(publicIpInfrastructure.getIp()));
- assertNotNull(publicIpCloud);
+ publicIpCloud = find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(publicIpInfrastructure.getIp());
+ }
+ });
}
@AfterClass
@@ -87,9 +91,15 @@ public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTes
assertEquals(nics.size(), 1);
assertEquals(nics.get(0).getId(), privateIp.getId());
- String address = publicIpCloud.getIp();
+ final String address = publicIpCloud.getIp();
env.virtualDatacenter.releasePublicIp(publicIpCloud);
- assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates.<PublicIp> address(address)));
+
+ assertNull(find(env.virtualDatacenter.listPurchasedPublicIps(), new Predicate<PublicIp>() {
+ @Override
+ public boolean apply(PublicIp input) {
+ return input.getIp().equals(address);
+ }
+ }, null));
}
// TODO: Infrastructure edit link for public ips can not be used to attach
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
index 05d2889..82a2708 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -27,9 +28,10 @@ import java.util.List;
import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link VirtualMachine} storage operations.
*
@@ -110,7 +112,12 @@ public class VirtualMachineStorageLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
private Volume createVolume() {
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Hawaian volume").sizeInMb(32).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
index 1a20e3a..a671989 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.cloud;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -29,11 +30,10 @@ import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.domain.network.PrivateNetwork;
import org.jclouds.abiquo.domain.task.AsyncTask;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.cloud.VolumePredicates;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link Volume} domain class.
@@ -44,7 +44,12 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testCreateVolume() {
// We need the vdc-relative tier
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Hawaian volume").sizeInMb(32).build();
@@ -71,8 +76,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
@Test(dependsOnMethods = "testFilterVolumes")
public void testUpdateVolume() {
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name(PREFIX + "Hawaian volume"));
- assertNotNull(volume);
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName(PREFIX + "Hawaian volume"));
volume.setName("Hawaian volume updated");
AsyncTask task = volume.update();
@@ -94,9 +98,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
newVdc.save();
assertNotNull(newVdc.getId());
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated"));
- assertNotNull(volume);
-
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName("Hawaian volume updated"));
volume.moveTo(newVdc);
// Check that the underlying Dto has been updated to the new VDC
@@ -115,8 +117,7 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
@Test(dependsOnMethods = "testMoveVolume")
public void testDeleteVolume() {
- Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated"));
- assertNotNull(volume);
+ Volume volume = find(env.virtualDatacenter.listVolumes(), volumeName("Hawaian volume updated"));
Integer id = volume.getId();
volume.delete();
@@ -124,4 +125,13 @@ public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertNull(env.virtualDatacenter.getVolume(id));
}
+ private static Predicate<Volume> volumeName(final String name) {
+ return new Predicate<Volume>() {
+ @Override
+ public boolean apply(Volume input) {
+ return input.getName().equals(name);
+ }
+ };
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
index 2341e3f..33cb292 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java
@@ -16,14 +16,15 @@
*/
package org.jclouds.abiquo.domain.config;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.CategoryPredicates;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link Category} domain class.
*
@@ -35,10 +36,12 @@ public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest {
Category category = Category.builder(env.context.getApiContext()).name(PREFIX + "-test-category").build();
category.save();
- Category apiCategory = env.context.getAdministrationService().findCategory(
- CategoryPredicates.name(PREFIX + "-test-category"));
- assertNotNull(apiCategory);
- assertEquals(category.getName(), apiCategory.getName());
+ Category apiCategory = find(env.context.getAdministrationService().listCategories(), new Predicate<Category>() {
+ @Override
+ public boolean apply(Category input) {
+ return input.getName().equals(PREFIX + "-test-category");
+ }
+ });
apiCategory.delete();
}
@@ -54,11 +57,12 @@ public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest {
category.setName(PREFIX + "-test-category-updated");
category.update();
- Category apiCategory = env.context.getAdministrationService().findCategory(
- CategoryPredicates.name(PREFIX + "-test-category-updated"));
-
- assertNotNull(apiCategory);
- assertEquals(PREFIX + "-test-category-updated", apiCategory.getName());
+ find(env.context.getAdministrationService().listCategories(), new Predicate<Category>() {
+ @Override
+ public boolean apply(Category input) {
+ return input.getName().equals(PREFIX + "-test-category-updated");
+ }
+ });
category.setName(name);
category.update();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
deleted file mode 100644
index 0a55f88..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.jclouds.abiquo.util.Assert.assertHasError;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import javax.ws.rs.core.Response.Status;
-
-import com.google.common.collect.Lists;
-
-import org.jclouds.abiquo.domain.exception.AbiquoException;
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Live integration tests for the {@link CostCode} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "CostCodeLiveApiTest")
-public class CostCodeLiveApiTest extends BaseAbiquoApiLiveApiTest {
- private CostCode costcode;
-
- private Currency currency;
-
- private CostCodePrice costcodeprice;
-
- private List<CostCodePrice> defaultPrices;
-
- @BeforeClass
- public void setupCostCode() {
- currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$")
- .digits(2).build();
- currency.save();
-
- costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode")
- .description("description").build();
-
- costcode.save();
- }
-
- @AfterClass
- public void tearDownCostCode() {
- currency.delete();
- costcode.delete();
- }
-
- public void testCreateRepeated() {
- CostCode repeated = CostCode.Builder.fromCostCode(costcode).build();
-
- try {
- repeated.save();
- fail("Should not be able to create costcodes with the same name");
- } catch (AbiquoException ex) {
- assertHasError(ex, Status.CONFLICT, "COSTCODE-2");
- }
- }
-
- public void testUpdate() {
- costcode.setName(PREFIX + "costcode-updated");
- costcode.update();
-
- CostCode apiCostCode = env.context.getPricingService().findCostCode(
- PricingPredicates.costCode(PREFIX + "costcode-updated"));
-
- assertNotNull(apiCostCode);
- assertEquals(PREFIX + "costcode-updated", apiCostCode.getName());
-
- }
-
- public void testCreateCostCodewithDefaultPrices() {
- CostCode costcode2 = CostCode.builder(env.context.getApiContext()).name(PREFIX + "ccdefaultprice")
- .description("description").build();
-
- costcodeprice = new CostCodePrice(currency, new BigDecimal(100));
- this.defaultPrices = Lists.newArrayList();
- defaultPrices.add(costcodeprice);
- costcode2.setDefaultPrices(defaultPrices);
- // When a cost code is created it is also created a costcodecurrency with
- // price 0 and after
- // that if a list of prices(CostCodePrice) has been sent this costcode is
- // updated with the
- // new price
- costcode2.save();
-
- // check that costcode has been created
- CostCode apiCostCode = env.context.getPricingService().findCostCode(
- PricingPredicates.costCode(PREFIX + "ccdefaultprice"));
-
- assertNotNull(apiCostCode);
- assertEquals(PREFIX + "ccdefaultprice", apiCostCode.getName());
-
- // check that the price has been modified in the
- Iterable<CostCodeCurrency> costcodecurrencies = env.context.getPricingService().getCostCodeCurrencies(
- costcode2.getId(), currency.getId());
- for (CostCodeCurrency costcodecurrency : costcodecurrencies) {
- assertEquals(costcodecurrency.getPrice().compareTo(new BigDecimal(100)), 0);
- }
-
- costcode2.delete();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
deleted file mode 100644
index 2bb7e1f..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.Test;
-
-/**
- * Live integration tests for the {@link Currency} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "CurrencyLiveApiTest")
-public class CurrencyLiveApiTest extends BaseAbiquoApiLiveApiTest {
- public void testCreateAndGet() {
- Currency currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$")
- .digits(2).build();
- currency.save();
-
- Currency apiCurrency = env.context.getPricingService().findCurrency(
- PricingPredicates.currency(PREFIX + "test-currency"));
- assertNotNull(apiCurrency);
- assertEquals(currency.getName(), apiCurrency.getName());
-
- apiCurrency.delete();
- }
-
- @Test(dependsOnMethods = "testCreateAndGet")
- public void testUpdate() {
- Iterable<Currency> currencies = env.context.getPricingService().listCurrencies();
- assertNotNull(currencies);
-
- Currency currency = currencies.iterator().next();
- String name = currency.getName();
-
- currency.setName(PREFIX + "t-currency-upd");
- currency.update();
-
- Currency apiCurrency = env.context.getPricingService().findCurrency(
- PricingPredicates.currency(PREFIX + "t-currency-upd"));
-
- assertNotNull(apiCurrency);
- assertEquals(PREFIX + "t-currency-upd", apiCurrency.getName());
-
- currency.setName(name);
- currency.update();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
deleted file mode 100644
index 9155f49..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain.config;
-
-import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
-import static org.jclouds.abiquo.util.Assert.assertHasError;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.math.BigDecimal;
-import java.util.Collection;
-import java.util.Date;
-
-import javax.ws.rs.core.Response.Status;
-
-import org.jclouds.abiquo.domain.exception.AbiquoException;
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.config.PricingPredicates;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.abiquo.model.enumerator.PricingPeriod;
-
-/**
- * Live integration tests for the {@link PricingTemplate} domain class.
- *
- * @author Susana Acedo
- */
-@Test(groups = "api", testName = "PricingTemplateLiveApiTest")
-public class PricingTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest {
- private PricingTemplate pricingTemplate;
-
- private Currency currency;
-
- private CostCode costcode;
-
- private BigDecimal zero = new BigDecimal(0);
-
- @BeforeClass
- public void setupPricingTemplate() {
- Iterable<Currency> currencies = env.context.getPricingService().listCurrencies();
- currency = currencies.iterator().next();
-
- costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode")
- .description("description").build();
-
- costcode.save();
-
- pricingTemplate = PricingTemplate.builder(env.context.getApiContext(), currency).name("pricing_template")
- .description("description").hdGB(zero).standingChargePeriod(zero).vlan(zero)
- .chargingPeriod(PricingPeriod.MONTH).minimumChargePeriod(zero).showChangesBefore(true)
- .showMinimumCharge(false).minimumCharge(PricingPeriod.WEEK).publicIp(zero).vcpu(zero).memoryGB(zero)
- .defaultTemplate(true).lastUpdate(new Date()).build();
-
- pricingTemplate.save();
- }
-
- @AfterClass
- public void tearDownPricingTemplate() {
- pricingTemplate.delete();
- costcode.delete();
- }
-
- public void testCreateRepeated() {
- PricingTemplate repeated = PricingTemplate.Builder.fromPricingTemplate(pricingTemplate).build();
-
- try {
- repeated.save();
- fail("Should not be able to create pricingtemplates with the same name");
- } catch (AbiquoException ex) {
- assertHasError(ex, Status.CONFLICT, "PRICINGTEMPLATE-2");
- }
- }
-
- public void testUpdate() {
- pricingTemplate.setName(PREFIX + "pt-updated");
- pricingTemplate.update();
-
- PricingTemplate apiPricingTemplate = env.context.getPricingService().findPricingTemplate(
- PricingPredicates.pricingTemplate(PREFIX + "pt-updated"));
-
- assertNotNull(apiPricingTemplate);
- assertEquals(PREFIX + "pt-updated", apiPricingTemplate.getName());
-
- }
-
- // when a pricing template is created, pricing cost codes for each existent
- // cost code are also
- // created with price 0
- public void getPricingCostCodes() {
- Collection<PricingCostCode> pricingCostCodes = env.context.getPricingService().getPricingCostCodes(
- pricingTemplate.getId());
- assertEquals(pricingCostCodes.size(), 1);
- assertNotNull(pricingCostCodes);
- for (PricingCostCode pc : pricingCostCodes) {
- assertEquals(pc.getPrice().compareTo(zero), 0);
- }
- }
-
- // when a pricing template is created, pricing tiers are also created with
- // price 0
- public void getPricingTiers() {
- Collection<PricingTier> pricingTiers =
-
- env.context.getPricingService().getPricingTiers(pricingTemplate.getId());
- assertEquals(pricingTiers.size(), 4);
- assertNotNull(pricingTiers);
- for (PricingTier pt : pricingTiers) {
- assertEquals(pt.getPrice().compareTo(zero), 0);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
index d9af7f3..b5909a5 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.abiquo.domain.enterprise;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.size;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
@@ -23,11 +25,12 @@ import static org.testng.Assert.assertNull;
import java.util.List;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.enterprise.TemplateDefinitionListPredicates;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.base.Predicate;
+
/**
* Live integration tests for the {@link TemplateDefinitionList} domain class.
*
@@ -41,10 +44,15 @@ public class TemplateDefinitionListLiveApiTest extends BaseAbiquoApiLiveApiTest
list.setName(list.getName() + "Updated");
list.update();
- List<TemplateDefinitionList> lists = env.enterprise.listTemplateDefinitionLists(TemplateDefinitionListPredicates
- .name("myListUpdated"));
+ Iterable<TemplateDefinitionList> lists = filter(env.enterprise.listTemplateDefinitionLists(),
+ new Predicate<TemplateDefinitionList>() {
+ @Override
+ public boolean apply(TemplateDefinitionList input) {
+ return input.getName().equals("myListUpdated");
+ }
+ });
- assertEquals(lists.size(), 1);
+ assertEquals(size(lists), 1);
}
public void testListStates() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
index 02dadec..4250431 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java
@@ -16,7 +16,9 @@
*/
package org.jclouds.abiquo.domain.enterprise;
-import static org.jclouds.abiquo.predicates.enterprise.UserPredicates.nick;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.size;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -26,10 +28,10 @@ import javax.ws.rs.core.Response.Status;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.enterprise.UserPredicates;
import org.testng.annotations.Test;
import com.abiquo.server.core.enterprise.UserDto;
+import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
@@ -69,7 +71,7 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
env.user.setRole(env.anotherRole);
env.user.update();
- Role role2 = env.enterprise.findUser(UserPredicates.nick(env.user.getNick())).getRole();
+ Role role2 = find(env.enterprise.listUsers(), nick(env.user.getNick())).getRole();
assertEquals(env.anotherRole.getId(), role2.getId());
assertEquals(role2.getName(), "Another role");
@@ -82,11 +84,11 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
Iterable<User> users = env.enterprise.listUsers();
assertEquals(Iterables.size(users), 2);
- users = env.enterprise.listUsers(nick(env.user.getNick()));
- assertEquals(Iterables.size(users), 1);
+ users = filter(env.enterprise.listUsers(), nick(env.user.getNick()));
+ assertEquals(size(users), 1);
- users = env.enterprise.listUsers(nick(env.user.getName() + "FAIL"));
- assertEquals(Iterables.size(users), 0);
+ users = filter(env.enterprise.listUsers(), nick(env.user.getName() + "FAIL"));
+ assertEquals(size(users), 0);
}
public void testGetCurrentUser() {
@@ -94,4 +96,13 @@ public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertNotNull(user);
assertEquals(user.getNick(), env.context.getApiContext().getIdentity());
}
+
+ private static Predicate<User> nick(final String nick) {
+ return new Predicate<User>() {
+ @Override
+ public boolean apply(User input) {
+ return input.getNick().equals(nick);
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
index d4e2dcf..5fd46e1 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.event;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -29,12 +30,12 @@ import org.jclouds.abiquo.domain.enterprise.User;
import org.jclouds.abiquo.domain.event.options.EventOptions;
import org.jclouds.abiquo.domain.infrastructure.Tier;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.TierPredicates;
import org.testng.annotations.Test;
import com.abiquo.model.enumerator.ComponentType;
import com.abiquo.model.enumerator.EventType;
import com.abiquo.model.enumerator.SeverityType;
+import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
@@ -81,8 +82,12 @@ public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
public void testListEventsFilteredByStoragePool() {
- Tier tier = env.datacenter.findTier(TierPredicates.name("Default Tier 2"));
- assertNotNull(tier);
+ Tier tier = find(env.datacenter.listTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals("Default Tier 2");
+ }
+ });
try {
env.storagePool.setTier(tier);
@@ -215,7 +220,13 @@ public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest {
}
private Volume createVolume() {
- Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName()));
+ Tier tier = find(env.virtualDatacenter.listStorageTiers(), new Predicate<Tier>() {
+ @Override
+ public boolean apply(Tier input) {
+ return input.getName().equals(env.tier.getName());
+ }
+ });
+
Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier)
.name(PREFIX + "Event vol").sizeInMb(32).build();
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
deleted file mode 100644
index 636ead6..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain.infrastructure;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.util.Config;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-/**
- * Live integration tests for the {@link Blade} domain class.
- *
- * @author Ignasi Barrera
- */
-@Test(groups = "ucs", testName = "BladeLiveUcsTest")
-public class BladeLiveUcsTest extends BaseAbiquoApiLiveApiTest {
- Blade blade;
-
- public void testFindAvailableVirtualSwitch() {
- String vswitch = Config.get("abiquo.hypervisor.vswitch");
- NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch);
- assertEquals(found, vswitch);
- }
-
- public void testGetRack() {
- ManagedRack rack = blade.getRack();
- assertNotNull(rack);
- assertEquals(rack.getId(), env.ucsRack.getId());
- }
-
- public void testListBlades() {
- Iterable<Blade> blades = env.ucsRack.listMachines();
- assertTrue(Iterables.size(blades) > 0);
- }
-
- public void testGetLogicServer() {
- LogicServer logicServer = blade.getLogicServer();
- assertNotNull(logicServer);
- assertNotNull(logicServer.getName());
- }
-
- public void testLedOn() {
- blade.ledOn();
- BladeLocatorLed led = blade.getLocatorLed();
- assertNotNull(led);
- assertEquals(led.getAdminStatus(), "on");
- }
-
- public void testLedOff() {
- blade.ledOff();
- BladeLocatorLed led = blade.getLocatorLed();
- assertNotNull(led);
- assertEquals(led.getAdminStatus(), "off");
- }
-
- @BeforeClass
- public void setup() {
- blade = env.ucsRack.listMachines().get(0);
- assertNotNull(blade);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
index 535860b..e4eafd7 100644
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
+++ b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.abiquo.domain.infrastructure;
+import static com.google.common.collect.Iterables.find;
import static org.jclouds.abiquo.util.Assert.assertHasError;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -32,7 +33,6 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachine;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.domain.exception.AbiquoException;
import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates;
import org.jclouds.abiquo.util.Config;
import org.testng.annotations.Test;
@@ -40,6 +40,7 @@ import com.abiquo.model.enumerator.HypervisorType;
import com.abiquo.model.enumerator.MachineState;
import com.abiquo.model.enumerator.RemoteServiceType;
import com.abiquo.server.core.infrastructure.MachineDto;
+import com.google.common.base.Predicate;
/**
* Live integration tests for the {@link Machine} domain class.
@@ -50,8 +51,12 @@ import com.abiquo.server.core.infrastructure.MachineDto;
public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
public void testDiscoverMachineWithouRemoteService() {
// Delete node collector
- RemoteService nc = env.datacenter.findRemoteService(RemoteServicePredicates
- .type(RemoteServiceType.NODE_COLLECTOR));
+ RemoteService nc = find(env.datacenter.listRemoteServices(), new Predicate<RemoteService>() {
+ @Override
+ public boolean apply(RemoteService input) {
+ return input.getType().equals(RemoteServiceType.NODE_COLLECTOR);
+ }
+ });
nc.delete();
try {
@@ -103,18 +108,6 @@ public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest {
assertEquals(machine.getState(), state);
}
- public void testFindDatastore() {
- Datastore datastore = env.machine.getDatastores().get(0);
- Datastore found = env.machine.findDatastore(datastore.getName());
- assertEquals(found.getName(), datastore.getName());
- }
-
- public void testFindAvailableVirtualSwitch() {
- String vswitch = Config.get("abiquo.hypervisor.vswitch");
- NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch);
- assertEquals(found.getName(), vswitch);
- }
-
public void testGetRack() {
Rack rack = env.machine.getRack();
assertNotNull(rack);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs/blob/c5e108a8/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
----------------------------------------------------------------------
diff --git a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java b/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
deleted file mode 100644
index 4c4e491..0000000
--- a/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.abiquo.domain.infrastructure;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest;
-import org.jclouds.abiquo.predicates.infrastructure.LogicServerPredicates;
-import org.jclouds.abiquo.predicates.infrastructure.ManagedRackPredicates;
-import org.testng.annotations.Test;
-
-import com.abiquo.server.core.infrastructure.UcsRackDto;
-import com.google.common.collect.Iterables;
-
-/**
- * Live integration tests for the {@link ManagedRack} domain class.
- *
- * @author Francesc Montserrat
- */
-@Test(groups = "ucs", testName = "ManagedRackLiveUcsTest")
-public class ManagedRackLiveUcsTest extends BaseAbiquoApiLiveApiTest {
- private LogicServer logicServer;
-
- private Organization organization;
-
- public void testUpdate() {
- env.ucsRack.setShortDescription("Updated description");
- env.ucsRack.update();
-
- // Recover the updated rack
- UcsRackDto updated = env.infrastructureApi.getManagedRack(env.datacenter.unwrap(), env.ucsRack.getId());
-
- assertEquals(updated.getShortDescription(), "Updated description");
- }
-
- public void testListManagedRacks() {
- Iterable<ManagedRack> racks = env.datacenter.listManagedRacks();
- assertEquals(Iterables.size(racks), 1);
-
- racks = env.datacenter.listManagedRacks(ManagedRackPredicates.name(env.ucsRack.getName()));
- assertEquals(Iterables.size(racks), 1);
- }
-
- public void testFindRack() {
- ManagedRack rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName()));
- assertNotNull(rack);
-
- rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName() + "FAIL"));
- assertNull(rack);
- }
-
- public void testCloneLogicServer() {
- List<LogicServer> originals = env.ucsRack.listServiceProfiles();
- assertNotNull(originals);
- assertTrue(originals.size() > 0);
- LogicServer original = originals.get(0);
-
- List<Organization> organizations = env.ucsRack.listOrganizations();
- assertNotNull(organizations);
- assertTrue(organizations.size() > 0);
- organization = organizations.get(0);
-
- env.ucsRack.cloneLogicServer(original, organization, "jclouds");
-
- logicServer = env.ucsRack
- .findServiceProfile(LogicServerPredicates.name(organization.getDn() + "/" + "ls-jclouds"));
- assertNotNull(logicServer);
-
- String name = logicServer.getName();
- assertEquals(name.substring(name.length() - 7, name.length()), "jclouds");
- }
-
- @Test(dependsOnMethods = "testCloneLogicServer")
- public void testListFsms() {
- List<Fsm> fsms = env.ucsRack.listFsm(logicServer.getName());
- assertNotNull(fsms);
- assertTrue(fsms.size() > 0);
- }
-
- @Test(dependsOnMethods = { "testCloneLogicServer", "testListFsms" })
- public void testDeleteLogicServer() {
- String name = logicServer.getName();
-
- env.ucsRack.deleteLogicServer(logicServer);
-
- LogicServer profile = env.ucsRack.findServiceProfile(LogicServerPredicates.name(name));
- assertNull(profile);
- }
-}