Cleanup unnecessary strategies

Removed all over engineering introduced by strategies that did
not perform anything else than a simple api call.
This commit is contained in:
Ignasi Barrera 2012-10-31 18:46:16 +01:00
parent cd330a759b
commit 5ba08d8448
37 changed files with 173 additions and 1851 deletions

View File

@ -19,8 +19,6 @@
package org.jclouds.abiquo.features.services;
import java.util.List;
import org.jclouds.abiquo.domain.config.Category;
import org.jclouds.abiquo.domain.config.License;
import org.jclouds.abiquo.domain.config.Privilege;
@ -67,11 +65,6 @@ public interface AdministrationService {
*/
Datacenter getDatacenter(final Integer datacenterId);
/**
* Get the list of datacenters with the given ids.
*/
Iterable<Datacenter> getDatacenters(final List<Integer> datacenterIds);
/*********************** Machine ***********************/
/**
@ -160,6 +153,15 @@ public interface AdministrationService {
*/
Privilege findPrivilege(final Predicate<Privilege> filter);
/**
* Get a privilege given its id.
*
* @param privilegeId
* The id of the privilege.
* @return The privilege.
*/
Privilege getPrivilege(Integer privilegeId);
/*********************** User ***********************/
/**
@ -245,4 +247,13 @@ public interface AdministrationService {
* <code>null</code> if none is found.
*/
Category findCategory(final Predicate<Category> filter);
/**
* Get the category identified by the given id.
*
* @param categoryId
* The id of the category.
* @return The requested category.
*/
Category getCategory(Integer categoryId);
}

View File

@ -59,6 +59,15 @@ public interface PricingService {
*/
Currency findCurrency(final Predicate<Currency> filter);
/**
* Get the currency with the given id.
*
* @param currencyId
* The id of the currency to get.
* @return The currency with the gicen id.
*/
Currency getCurrency(final Integer currencyId);
/*********************** CostCode ***********************/
/**
@ -77,37 +86,55 @@ public interface PricingService {
*/
CostCode findCostCode(final Predicate<CostCode> filter);
/**
* Get a cost code given its id.
*
* @param costCodeId
* The id of the cost code.
* @return The cost code.
*/
CostCode getCostCode(Integer costCodeId);
/*********************** PricingTemplate ***********************/
/**
* Get the list of pricingtemplates.
*/
public Iterable<PricingTemplate> listPricingTemplates();
Iterable<PricingTemplate> listPricingTemplates();
/**
* Get the list of pricingtemplates matching the given filter.
*/
public Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter);
Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter);
/**
* Get the first pricingtemplates that matches the given filter or
* <code>null</code> if none is found.
*/
public PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter);
PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter);
/**
* Get a pricing template given its id.
*
* @param pricingTemplateId
* The id of the pricing template.
* @return The pricing template.
*/
PricingTemplate getPricingTemplate(Integer pricingTemplateId);
/*********************** CostCodeCurrency ***********************/
/**
* Get a cost code currency
*/
public Iterable<CostCodeCurrency> getCostCodeCurrencies(Integer costcodeid, Integer currencyid);
Iterable<CostCodeCurrency> getCostCodeCurrencies(Integer costcodeid, Integer currencyid);
/*********************** PricingCostCode ***********************/
/**
* Get pricing cost codes
*/
public Collection<PricingCostCode> getPricingCostCodes(Integer pricingTemplateId);
Collection<PricingCostCode> getPricingCostCodes(Integer pricingTemplateId);
/**
* Get a pricing cost code

View File

@ -20,15 +20,15 @@
package org.jclouds.abiquo.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getFirst;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.config.Category;
import org.jclouds.abiquo.domain.config.License;
import org.jclouds.abiquo.domain.config.Privilege;
@ -43,21 +43,23 @@ import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Machine;
import org.jclouds.abiquo.features.services.AdministrationService;
import org.jclouds.abiquo.reference.ValidationErrors;
import org.jclouds.abiquo.strategy.admin.ListRoles;
import org.jclouds.abiquo.strategy.config.ListCategories;
import org.jclouds.abiquo.strategy.config.ListLicenses;
import org.jclouds.abiquo.strategy.config.ListPrivileges;
import org.jclouds.abiquo.strategy.config.ListProperties;
import org.jclouds.abiquo.strategy.enterprise.ListEnterprises;
import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters;
import org.jclouds.abiquo.strategy.infrastructure.ListMachines;
import org.jclouds.collect.Memoized;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.appslibrary.CategoriesDto;
import com.abiquo.server.core.appslibrary.CategoryDto;
import com.abiquo.server.core.config.LicensesDto;
import com.abiquo.server.core.config.SystemPropertiesDto;
import com.abiquo.server.core.enterprise.EnterpriseDto;
import com.abiquo.server.core.enterprise.EnterprisePropertiesDto;
import com.abiquo.server.core.enterprise.EnterprisesDto;
import com.abiquo.server.core.enterprise.PrivilegeDto;
import com.abiquo.server.core.enterprise.PrivilegesDto;
import com.abiquo.server.core.enterprise.RoleDto;
import com.abiquo.server.core.enterprise.RolesDto;
import com.abiquo.server.core.infrastructure.DatacenterDto;
import com.abiquo.server.core.infrastructure.DatacentersDto;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@ -74,30 +76,9 @@ public class BaseAdministrationService implements AdministrationService {
@VisibleForTesting
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
@VisibleForTesting
protected final ListDatacenters listDatacenters;
@VisibleForTesting
protected final ListMachines listMachines;
@VisibleForTesting
protected final ListEnterprises listEnterprises;
@VisibleForTesting
protected final ListRoles listRoles;
@VisibleForTesting
protected final ListLicenses listLicenses;
@VisibleForTesting
protected final ListPrivileges listPrivileges;
@VisibleForTesting
protected final ListProperties listProperties;
@VisibleForTesting
protected final ListCategories listCategories;
@VisibleForTesting
protected final Supplier<User> currentUser;
@ -106,19 +87,10 @@ public class BaseAdministrationService implements AdministrationService {
@Inject
protected BaseAdministrationService(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
final ListDatacenters listDatacenters, final ListMachines listMachines, final ListEnterprises listEnterprises,
final ListRoles listRoles, final ListLicenses listLicenses, final ListPrivileges listPrivileges,
final ListProperties listProperties, final ListCategories listCategories,
@Memoized final Supplier<User> currentUser, @Memoized final Supplier<Enterprise> currentEnterprise) {
final ListMachines listMachines, @Memoized final Supplier<User> currentUser,
@Memoized final Supplier<Enterprise> currentEnterprise) {
this.context = checkNotNull(context, "context");
this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters");
this.listMachines = checkNotNull(listMachines, "listMachines");
this.listEnterprises = checkNotNull(listEnterprises, "listEnterprises");
this.listRoles = checkNotNull(listRoles, "listRoles");
this.listLicenses = checkNotNull(listLicenses, "listLicenses");
this.listPrivileges = checkNotNull(listPrivileges, "listPrivileges");
this.listProperties = checkNotNull(listProperties, "listProperties");
this.listCategories = checkNotNull(listCategories, "listCategories");
this.currentUser = checkNotNull(currentUser, "currentUser");
this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise");
}
@ -127,12 +99,18 @@ public class BaseAdministrationService implements AdministrationService {
@Override
public Iterable<Datacenter> listDatacenters() {
return listDatacenters.execute();
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
return wrap(context, Datacenter.class, result.getCollection());
}
@Override
public Iterable<Datacenter> listDatacenters(final Predicate<Datacenter> filter) {
return listDatacenters.execute(filter);
return filter(listDatacenters(), filter);
}
@Override
public Datacenter findDatacenter(final Predicate<Datacenter> filter) {
return getFirst(listDatacenters(filter), null);
}
@Override
@ -141,16 +119,6 @@ public class BaseAdministrationService implements AdministrationService {
return wrap(context, Datacenter.class, datacenter);
}
@Override
public Datacenter findDatacenter(final Predicate<Datacenter> filter) {
return Iterables.getFirst(listDatacenters(filter), null);
}
@Override
public Iterable<Datacenter> getDatacenters(final List<Integer> datacenterIds) {
return listDatacenters.execute(datacenterIds);
}
/*********************** Machine ***********************/
@Override
@ -172,12 +140,13 @@ public class BaseAdministrationService implements AdministrationService {
@Override
public Iterable<Enterprise> listEnterprises() {
return listEnterprises.execute();
EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises();
return wrap(context, Enterprise.class, result.getCollection());
}
@Override
public Iterable<Enterprise> listEnterprises(final Predicate<Enterprise> filter) {
return listEnterprises.execute(filter);
return filter(listEnterprises(), filter);
}
@Override
@ -206,17 +175,18 @@ public class BaseAdministrationService implements AdministrationService {
@Override
public Iterable<Role> listRoles() {
return listRoles.execute();
RolesDto result = context.getApi().getAdminApi().listRoles();
return wrap(context, Role.class, result.getCollection());
}
@Override
public Iterable<Role> listRoles(final Predicate<Role> filter) {
return listRoles.execute(filter);
return filter(listRoles(), filter);
}
@Override
public Role findRole(final Predicate<Role> filter) {
return Iterables.getFirst(listRoles(filter), null);
return getFirst(listRoles(filter), null);
}
@Override
@ -227,19 +197,26 @@ public class BaseAdministrationService implements AdministrationService {
/*********************** Privilege ***********************/
@Override
public Privilege findPrivilege(final Predicate<Privilege> filter) {
return Iterables.getFirst(listPrivileges(filter), null);
}
@Override
public Iterable<Privilege> listPrivileges() {
return listPrivileges.execute();
PrivilegesDto result = context.getApi().getConfigApi().listPrivileges();
return wrap(context, Privilege.class, result.getCollection());
}
@Override
public Iterable<Privilege> listPrivileges(final Predicate<Privilege> filter) {
return listPrivileges.execute(filter);
return filter(listPrivileges(), filter);
}
@Override
public Privilege findPrivilege(final Predicate<Privilege> filter) {
return getFirst(listPrivileges(filter), null);
}
@Override
public Privilege getPrivilege(Integer privilegeId) {
PrivilegeDto result = context.getApi().getConfigApi().getPrivilege(privilegeId);
return wrap(context, Privilege.class, result);
}
/*********************** User ***********************/
@ -258,52 +235,68 @@ public class BaseAdministrationService implements AdministrationService {
@Override
public Iterable<License> listLicenses() {
return listLicenses.execute();
LicensesDto result = context.getApi().getConfigApi().listLicenses();
return wrap(context, License.class, result.getCollection());
}
@Override
public Iterable<License> listLicenses(final boolean active) {
LicenseOptions options = LicenseOptions.builder().active(active).build();
return listLicenses.execute(options);
LicensesDto result = context.getApi().getConfigApi().listLicenses(options);
return wrap(context, License.class, result.getCollection());
}
@Override
public Iterable<License> listLicenses(final Predicate<License> filter) {
return listLicenses.execute(filter);
return filter(listLicenses(), filter);
}
@Override
public License findLicense(final Predicate<License> filter) {
return Iterables.getFirst(listLicenses(filter), null);
return getFirst(listLicenses(filter), null);
}
/*********************** System Properties ***********************/
@Override
public Iterable<SystemProperty> listSystemProperties() {
return listProperties.execute();
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties();
return wrap(context, SystemProperty.class, result.getCollection());
}
@Override
public Iterable<SystemProperty> listSystemProperties(final Predicate<SystemProperty> filter) {
return listProperties.execute(filter);
return filter(listSystemProperties(), filter);
}
@Override
public SystemProperty findSystemProperty(final Predicate<SystemProperty> filter) {
return Iterables.getFirst(listSystemProperties(filter), null);
return getFirst(listSystemProperties(filter), null);
}
@Override
public SystemProperty getSystemProperty(final String name) {
PropertyOptions options = PropertyOptions.builder().name(name).build();
return Iterables.getFirst(listProperties.execute(options), null);
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options);
return getFirst(wrap(context, SystemProperty.class, result.getCollection()), null);
}
@Override
public Iterable<SystemProperty> listSystemProperties(final String component) {
PropertyOptions options = PropertyOptions.builder().component(component).build();
return listProperties.execute(options);
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options);
return wrap(context, SystemProperty.class, result.getCollection());
}
@Override
public Iterable<Category> listCategories() {
CategoriesDto result = context.getApi().getConfigApi().listCategories();
return wrap(context, Category.class, result.getCollection());
}
@Override
public Iterable<Category> listCategories(final Predicate<Category> filter) {
return filter(listCategories(), filter);
}
@Override
@ -312,12 +305,8 @@ public class BaseAdministrationService implements AdministrationService {
}
@Override
public Iterable<Category> listCategories() {
return listCategories.execute();
}
@Override
public Iterable<Category> listCategories(final Predicate<Category> filter) {
return listCategories.execute(filter);
public Category getCategory(Integer categoryId) {
CategoryDto result = context.getApi().getConfigApi().getCategory(categoryId);
return wrap(context, Category.class, result);
}
}

View File

@ -20,18 +20,19 @@
package org.jclouds.abiquo.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.event.Event;
import org.jclouds.abiquo.domain.event.options.EventOptions;
import org.jclouds.abiquo.features.services.EventService;
import org.jclouds.abiquo.strategy.event.ListEvents;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.event.EventsDto;
import com.google.common.annotations.VisibleForTesting;
/**
@ -45,22 +46,20 @@ public class BaseEventService implements EventService {
@VisibleForTesting
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
@VisibleForTesting
protected final ListEvents listEvents;
@Inject
protected BaseEventService(final RestContext<AbiquoApi, AbiquoAsyncApi> context, final ListEvents listEvents) {
protected BaseEventService(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = checkNotNull(context, "context");
this.listEvents = checkNotNull(listEvents, "listEvents");
}
@Override
public Iterable<Event> listEvents() {
return listEvents.execute();
EventsDto result = context.getApi().getEventApi().listEvents();
return wrap(context, Event.class, result.getCollection());
}
@Override
public Iterable<Event> listEvents(final EventOptions options) {
return listEvents.execute(options);
EventsDto result = context.getApi().getEventApi().listEvents(options);
return wrap(context, Event.class, result.getCollection());
}
}

View File

@ -20,6 +20,8 @@
package org.jclouds.abiquo.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getFirst;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import java.util.Collection;
@ -36,14 +38,17 @@ import org.jclouds.abiquo.domain.config.PricingCostCode;
import org.jclouds.abiquo.domain.config.PricingTemplate;
import org.jclouds.abiquo.domain.config.PricingTier;
import org.jclouds.abiquo.features.services.PricingService;
import org.jclouds.abiquo.strategy.config.ListCostCodes;
import org.jclouds.abiquo.strategy.config.ListCurrencies;
import org.jclouds.abiquo.strategy.config.ListPricingTemplates;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.pricing.CostCodeCurrenciesDto;
import com.abiquo.server.core.pricing.CostCodeDto;
import com.abiquo.server.core.pricing.CostCodesDto;
import com.abiquo.server.core.pricing.CurrenciesDto;
import com.abiquo.server.core.pricing.CurrencyDto;
import com.abiquo.server.core.pricing.PricingCostCodeDto;
import com.abiquo.server.core.pricing.PricingCostCodesDto;
import com.abiquo.server.core.pricing.PricingTemplateDto;
import com.abiquo.server.core.pricing.PricingTemplatesDto;
import com.abiquo.server.core.pricing.PricingTierDto;
import com.abiquo.server.core.pricing.PricingTiersDto;
import com.google.common.annotations.VisibleForTesting;
@ -51,7 +56,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
* Provides high level Abiquo administration operations.
* Provides access to Abiquo pricing features.
*
* @author Ignasi Barrera
* @author Susana Acedo
@ -61,52 +66,46 @@ public class BasePricingService implements PricingService {
@VisibleForTesting
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
@VisibleForTesting
protected final ListCurrencies listCurrencies;
@VisibleForTesting
protected final ListCostCodes listCostCodes;
@VisibleForTesting
protected final ListPricingTemplates listPricingTemplates;
@Inject
protected BasePricingService(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
final ListCurrencies listCurrencies, final ListCostCodes listCostCodes,
final ListPricingTemplates listPricingTemplates) {
protected BasePricingService(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = checkNotNull(context, "context");
this.listCurrencies = checkNotNull(listCurrencies, "listCurrencies");
this.listCostCodes = checkNotNull(listCostCodes, "listCostCodes");
this.listPricingTemplates = checkNotNull(listPricingTemplates, "listPricingTemplates");
}
/*********************** Currency ********************** */
@Override
public Iterable<Currency> listCurrencies() {
return listCurrencies.execute();
CurrenciesDto result = context.getApi().getPricingApi().listCurrencies();
return wrap(context, Currency.class, result.getCollection());
}
@Override
public Iterable<Currency> listCurrencies(final Predicate<Currency> filter) {
return listCurrencies.execute(filter);
return filter(listCurrencies(), filter);
}
@Override
public Currency findCurrency(final Predicate<Currency> filter) {
return Iterables.getFirst(listCurrencies(filter), null);
return getFirst(listCurrencies(filter), null);
}
@Override
public Currency getCurrency(final Integer currencyId) {
CurrencyDto result = context.getApi().getPricingApi().getCurrency(currencyId);
return wrap(context, Currency.class, result);
}
/*********************** CostCode ********************** */
@Override
public Iterable<CostCode> listCostCodes() {
return listCostCodes.execute();
CostCodesDto result = context.getApi().getPricingApi().listCostCodes();
return wrap(context, CostCode.class, result.getCollection());
}
@Override
public Iterable<CostCode> listCostCodes(final Predicate<CostCode> filter) {
return listCostCodes.execute(filter);
return filter(listCostCodes(), filter);
}
@Override
@ -114,21 +113,34 @@ public class BasePricingService implements PricingService {
return Iterables.getFirst(listCostCodes(filter), null);
}
@Override
public CostCode getCostCode(Integer costCodeId) {
CostCodeDto result = context.getApi().getPricingApi().getCostCode(costCodeId);
return wrap(context, CostCode.class, result);
}
/*********************** PricingTemplate ********************** */
@Override
public Iterable<PricingTemplate> listPricingTemplates() {
return listPricingTemplates.execute();
PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates();
return wrap(context, PricingTemplate.class, result.getCollection());
}
@Override
public Iterable<PricingTemplate> listPricingTemplates(final Predicate<PricingTemplate> filter) {
return listPricingTemplates.execute(filter);
return filter(listPricingTemplates(), filter);
}
@Override
public PricingTemplate findPricingTemplate(final Predicate<PricingTemplate> filter) {
return Iterables.getFirst(listPricingTemplates(filter), null);
return getFirst(listPricingTemplates(filter), null);
}
@Override
public PricingTemplate getPricingTemplate(Integer pricingTemplateId) {
PricingTemplateDto result = context.getApi().getPricingApi().getPricingTemplate(pricingTemplateId);
return wrap(context, PricingTemplate.class, result);
}
/*********************** CostCodeCurrency ********************** */

View File

@ -1,36 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.admin;
import org.jclouds.abiquo.domain.enterprise.Role;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.admin.internal.ListRolesImpl;
import com.google.inject.ImplementedBy;
/**
* List roles.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListRolesImpl.class)
public interface ListRoles extends ListRootEntities<Role> {
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.admin.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.enterprise.Role;
import org.jclouds.abiquo.strategy.admin.ListRoles;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.enterprise.RolesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List enterprises.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListRolesImpl implements ListRoles {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListRolesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Role> execute() {
RolesDto result = context.getApi().getAdminApi().listRoles();
return wrap(context, Role.class, result.getCollection());
}
@Override
public Iterable<Role> execute(final Predicate<Role> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,35 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.Category;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListCategoriesImpl;
import com.google.inject.ImplementedBy;
/**
* List privileges.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListCategoriesImpl.class)
public interface ListCategories extends ListRootEntities<Category> {
}

View File

@ -1,36 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.CostCode;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListCostCodesImpl;
import com.google.inject.ImplementedBy;
/**
* List cost codes
*
* @author Susana Acedo
*/
@ImplementedBy(ListCostCodesImpl.class)
public interface ListCostCodes extends ListRootEntities<CostCode> {
}

View File

@ -1,36 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.Currency;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListCurrenciesImpl;
import com.google.inject.ImplementedBy;
/**
* List currencies
*
* @author Susana Acedo
*/
@ImplementedBy(ListCurrenciesImpl.class)
public interface ListCurrencies extends ListRootEntities<Currency> {
}

View File

@ -1,37 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.License;
import org.jclouds.abiquo.domain.config.options.LicenseOptions;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListLicensesImpl;
import com.google.inject.ImplementedBy;
/**
* List licenses.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListLicensesImpl.class)
public interface ListLicenses extends ListRootEntities<License> {
public Iterable<License> execute(LicenseOptions options);
}

View File

@ -1,36 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.PricingTemplate;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListPricingTemplatesImpl;
import com.google.inject.ImplementedBy;
/**
* List pricing templates
*
* @author Susana Acedo
*/
@ImplementedBy(ListPricingTemplatesImpl.class)
public interface ListPricingTemplates extends ListRootEntities<PricingTemplate> {
}

View File

@ -1,35 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListPrivilegesImpl;
import com.google.inject.ImplementedBy;
/**
* List privileges.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListPrivilegesImpl.class)
public interface ListPrivileges extends ListRootEntities<Privilege> {
}

View File

@ -1,37 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config;
import org.jclouds.abiquo.domain.config.SystemProperty;
import org.jclouds.abiquo.domain.config.options.PropertyOptions;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.config.internal.ListPropertiesImpl;
import com.google.inject.ImplementedBy;
/**
* List system properties.
*
* @author Francesc Montserrat
*/
@ImplementedBy(ListPropertiesImpl.class)
public interface ListProperties extends ListRootEntities<SystemProperty> {
public Iterable<SystemProperty> execute(PropertyOptions options);
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.config.Category;
import org.jclouds.abiquo.strategy.config.ListCategories;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.appslibrary.CategoriesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List categories.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListCategoriesImpl implements ListCategories {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListCategoriesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Category> execute() {
CategoriesDto result = context.getApi().getConfigApi().listCategories();
return wrap(context, Category.class, result.getCollection());
}
@Override
public Iterable<Category> execute(final Predicate<Category> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.config.CostCode;
import org.jclouds.abiquo.strategy.config.ListCostCodes;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.pricing.CostCodesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List cost codes
*
* @author Ignasi Barrera
* @author Susana Acedo
*/
@Singleton
public class ListCostCodesImpl implements ListCostCodes {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListCostCodesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<CostCode> execute() {
CostCodesDto result = context.getApi().getPricingApi().listCostCodes();
return wrap(context, CostCode.class, result.getCollection());
}
@Override
public Iterable<CostCode> execute(final Predicate<CostCode> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.config.Currency;
import org.jclouds.abiquo.strategy.config.ListCurrencies;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.pricing.CurrenciesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List currencies
*
* @author Ignasi Barrera
* @author Susana Acedo
*/
@Singleton
public class ListCurrenciesImpl implements ListCurrencies {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListCurrenciesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Currency> execute() {
CurrenciesDto result = context.getApi().getPricingApi().listCurrencies();
return wrap(context, Currency.class, result.getCollection());
}
@Override
public Iterable<Currency> execute(final Predicate<Currency> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,74 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.config.License;
import org.jclouds.abiquo.domain.config.options.LicenseOptions;
import org.jclouds.abiquo.strategy.config.ListLicenses;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.config.LicensesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List licenses.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListLicensesImpl implements ListLicenses {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListLicensesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<License> execute() {
LicensesDto result = context.getApi().getConfigApi().listLicenses();
return wrap(context, License.class, result.getCollection());
}
@Override
public Iterable<License> execute(final LicenseOptions options) {
LicensesDto result = context.getApi().getConfigApi().listLicenses(options);
return wrap(context, License.class, result.getCollection());
}
@Override
public Iterable<License> execute(final Predicate<License> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.config.PricingTemplate;
import org.jclouds.abiquo.strategy.config.ListPricingTemplates;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.pricing.PricingTemplatesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List pricing templates
*
* @author Ignasi Barrera
* @author Susana Acedo
*/
@Singleton
public class ListPricingTemplatesImpl implements ListPricingTemplates {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListPricingTemplatesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<PricingTemplate> execute() {
PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates();
return wrap(context, PricingTemplate.class, result.getCollection());
}
@Override
public Iterable<PricingTemplate> execute(final Predicate<PricingTemplate> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.strategy.config.ListPrivileges;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.enterprise.PrivilegesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List licenses.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListPrivilegesImpl implements ListPrivileges {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListPrivilegesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Privilege> execute() {
PrivilegesDto result = context.getApi().getConfigApi().listPrivileges();
return wrap(context, Privilege.class, result.getCollection());
}
@Override
public Iterable<Privilege> execute(final Predicate<Privilege> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,73 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.config.SystemProperty;
import org.jclouds.abiquo.domain.config.options.PropertyOptions;
import org.jclouds.abiquo.strategy.config.ListProperties;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.config.SystemPropertiesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List properties.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListPropertiesImpl implements ListProperties {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListPropertiesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<SystemProperty> execute() {
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties();
return wrap(context, SystemProperty.class, result.getCollection());
}
@Override
public Iterable<SystemProperty> execute(final Predicate<SystemProperty> selector) {
return filter(execute(), selector);
}
@Override
public Iterable<SystemProperty> execute(final PropertyOptions options) {
SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options);
return wrap(context, SystemProperty.class, result.getCollection());
}
}

View File

@ -1,36 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.enterprise;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.enterprise.internal.ListEnterprisesImpl;
import com.google.inject.ImplementedBy;
/**
* List enterprises.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListEnterprisesImpl.class)
public interface ListEnterprises extends ListRootEntities<Enterprise> {
}

View File

@ -1,67 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.enterprise.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import javax.inject.Singleton;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.strategy.enterprise.ListEnterprises;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.enterprise.EnterprisesDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
/**
* List enterprises.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListEnterprisesImpl implements ListEnterprises {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListEnterprisesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Enterprise> execute() {
EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises();
return wrap(context, Enterprise.class, result.getCollection());
}
@Override
public Iterable<Enterprise> execute(final Predicate<Enterprise> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,37 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.event;
import org.jclouds.abiquo.domain.event.Event;
import org.jclouds.abiquo.domain.event.options.EventOptions;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.event.internal.ListEventsImpl;
import com.google.inject.ImplementedBy;
/**
* List events.
*
* @author Vivien Mahé
*/
@ImplementedBy(ListEventsImpl.class)
public interface ListEvents extends ListRootEntities<Event> {
Iterable<Event> execute(EventOptions options);
}

View File

@ -1,65 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.event.internal;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.event.Event;
import org.jclouds.abiquo.domain.event.options.EventOptions;
import org.jclouds.abiquo.strategy.event.ListEvents;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.event.EventsDto;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
public class ListEventsImpl implements ListEvents {
// This strategy does not have still an Executor instance because the current
// methods call
// single api methods
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
@Inject
ListEventsImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context) {
this.context = context;
}
@Override
public Iterable<Event> execute() {
EventsDto result = context.getApi().getEventApi().listEvents();
return wrap(context, Event.class, result.getCollection());
}
@Override
public Iterable<Event> execute(final EventOptions options) {
EventsDto result = context.getApi().getEventApi().listEvents(options);
return wrap(context, Event.class, result.getCollection());
}
@Override
public Iterable<Event> execute(final Predicate<Event> selector) {
return filter(execute(), selector);
}
}

View File

@ -1,38 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.infrastructure;
import java.util.List;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.strategy.ListRootEntities;
import org.jclouds.abiquo.strategy.infrastructure.internal.ListDatacentersImpl;
import com.google.inject.ImplementedBy;
/**
* List datacenters.
*
* @author Ignasi Barrera
*/
@ImplementedBy(ListDatacentersImpl.class)
public interface ListDatacenters extends ListRootEntities<Datacenter> {
Iterable<Datacenter> execute(List<Integer> datacenterIds);
}

View File

@ -1,106 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.infrastructure.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.abiquo.domain.DomainWrapper.wrap;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters;
import org.jclouds.logging.Logger;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.infrastructure.DatacenterDto;
import com.abiquo.server.core.infrastructure.DatacentersDto;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
/**
* List datacenters.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Singleton
public class ListDatacentersImpl implements ListDatacenters {
protected final RestContext<AbiquoApi, AbiquoAsyncApi> context;
protected final ExecutorService userExecutor;
@Resource
protected Logger logger = Logger.NULL;
@Inject(optional = true)
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
protected Long maxTime;
@Inject
ListDatacentersImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
this.context = context;
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
}
@Override
public Iterable<Datacenter> execute() {
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
return wrap(context, Datacenter.class, result.getCollection());
}
@Override
public Iterable<Datacenter> execute(final Predicate<Datacenter> selector) {
return filter(execute(), selector);
}
@Override
public Iterable<Datacenter> execute(final List<Integer> datacenterIds) {
// Find virtual datacenters in concurrent requests
return listConcurrentDatacenters(datacenterIds);
}
private Iterable<Datacenter> listConcurrentDatacenters(final List<Integer> ids) {
Iterable<DatacenterDto> dcs = transformParallel(ids, new Function<Integer, Future<? extends DatacenterDto>>() {
@Override
public Future<DatacenterDto> apply(final Integer input) {
return context.getAsyncApi().getInfrastructureApi().getDatacenter(input);
}
}, userExecutor, maxTime, logger, "getting datacenters");
return DomainWrapper.wrap(context, Datacenter.class, Lists.newArrayList(dcs));
}
}

View File

@ -32,16 +32,16 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.AbiquoApi;
import org.jclouds.abiquo.AbiquoAsyncApi;
import org.jclouds.abiquo.domain.DomainWrapper;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.domain.infrastructure.Machine;
import org.jclouds.abiquo.strategy.infrastructure.ListDatacenters;
import org.jclouds.abiquo.strategy.infrastructure.ListMachines;
import org.jclouds.logging.Logger;
import org.jclouds.rest.RestContext;
import com.abiquo.server.core.infrastructure.DatacentersDto;
import com.abiquo.server.core.infrastructure.MachineDto;
import com.abiquo.server.core.infrastructure.MachinesDto;
import com.abiquo.server.core.infrastructure.RackDto;
@ -59,8 +59,6 @@ import com.google.inject.Inject;
public class ListMachinesImpl implements ListMachines {
protected RestContext<AbiquoApi, AbiquoAsyncApi> context;
protected ListDatacenters listDatacenters;
protected final ExecutorService userExecutor;
@Resource
@ -72,18 +70,17 @@ public class ListMachinesImpl implements ListMachines {
@Inject
ListMachinesImpl(final RestContext<AbiquoApi, AbiquoAsyncApi> context,
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor,
final ListDatacenters listDatacenters) {
@Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) {
super();
this.context = checkNotNull(context, "context");
this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters");
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
}
@Override
public Iterable<Machine> execute() {
// Find machines in concurrent requests
Iterable<Datacenter> datacenters = listDatacenters.execute();
DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters();
Iterable<Datacenter> datacenters = wrap(context, Datacenter.class, result.getCollection());
Iterable<RackDto> racks = listConcurrentRacks(datacenters);
Iterable<MachineDto> machines = listConcurrentMachines(racks);

View File

@ -36,12 +36,7 @@ public class BaseAdministrationServiceTest extends BaseInjectionTest {
BaseAdministrationService service = (BaseAdministrationService) injector.getInstance(AdministrationService.class);
assertNotNull(service.context);
assertNotNull(service.listDatacenters);
assertNotNull(service.listMachines);
assertNotNull(service.listEnterprises);
assertNotNull(service.listLicenses);
assertNotNull(service.listPrivileges);
assertNotNull(service.listRoles);
assertNotNull(service.currentUser);
assertNotNull(service.currentEnterprise);
}

View File

@ -35,6 +35,5 @@ public class BaseEventServiceTest extends BaseInjectionTest {
BaseEventService service = (BaseEventService) injector.getInstance(EventService.class);
assertNotNull(service.context);
assertNotNull(service.listEvents);
}
}

View File

@ -1,65 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.admin.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.enterprise.Role;
import org.jclouds.abiquo.predicates.enterprise.RolePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Live tests for the {@link ListRolesImpl} strategy.
*
* @author Ignasi Barrera
*/
@Test(groups = "api", testName = "ListRolesImplLiveApiTest")
public class ListRolesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListRolesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListRolesImpl.class);
}
public void testExecute() {
Iterable<Role> roles = strategy.execute();
assertNotNull(roles);
assertTrue(size(roles) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<Role> roles = strategy.execute(RolePredicates.name("UNEXISTING"));
assertNotNull(roles);
assertEquals(size(roles), 0);
}
public void testExecutePredicateWithResults() {
Iterable<Role> roles = strategy.execute(RolePredicates.name(env.role.getName()));
assertNotNull(roles);
assertEquals(size(roles), 1);
}
}

View File

@ -1,78 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.config.Category;
import org.jclouds.abiquo.predicates.config.CategoryPredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
/**
* Live tests for the {@link ListPropertiesImpl} strategy.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Test(groups = "api", testName = "ListCategoriesImplLiveApiTest")
public class ListCategoriesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListCategoriesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListCategoriesImpl.class);
}
public void testExecute() {
Iterable<Category> categories = strategy.execute();
assertNotNull(categories);
assertTrue(size(categories) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<Category> categories = strategy.execute(CategoryPredicates.name("Unexisting category"));
assertNotNull(categories);
assertEquals(size(categories), 0);
}
public void testExecutePredicateWithResults() {
Iterable<Category> categories = strategy.execute(CategoryPredicates.name("Applications servers"));
assertNotNull(categories);
assertEquals(size(categories), 1);
}
public void testExecuteNotPredicateWithResults() {
Iterable<Category> categories = strategy.execute(Predicates.not(CategoryPredicates.name("Applications servers")));
Iterable<Category> allProperties = strategy.execute();
assertNotNull(categories);
assertNotNull(allProperties);
assertEquals(size(categories), size(allProperties) - 1);
}
}

View File

@ -1,82 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.config.License;
import org.jclouds.abiquo.domain.config.options.LicenseOptions;
import org.jclouds.abiquo.predicates.config.LicensePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Live tests for the {@link ListLicenseImpl} strategy.
*
* @author Ignasi Barrera
*/
@Test(groups = "api", testName = "ListLicensesImplLiveApiTest")
public class ListLicensesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListLicensesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListLicensesImpl.class);
}
public void testExecute() {
Iterable<License> licenses = strategy.execute();
assertNotNull(licenses);
assertTrue(size(licenses) > 0);
}
public void testExecuteInactive() {
LicenseOptions options = LicenseOptions.builder().inactive(true).build();
Iterable<License> licenses = strategy.execute(options);
assertNotNull(licenses);
assertTrue(size(licenses) == 1);
}
public void testExecuteActive() {
LicenseOptions options = LicenseOptions.builder().active(true).build();
Iterable<License> licenses = strategy.execute(options);
assertNotNull(licenses);
assertTrue(size(licenses) >= 1);
}
public void testExecutePredicateWithoutResults() {
Iterable<License> licenses = strategy.execute(LicensePredicates.customer("FAIL"));
assertNotNull(licenses);
assertEquals(size(licenses), 0);
}
public void testExecutePredicateWithResults() {
Iterable<License> licenses = strategy.execute(LicensePredicates.code(env.license.getCode()));
assertNotNull(licenses);
assertEquals(size(licenses), 1);
}
}

View File

@ -1,77 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.config.Privilege;
import org.jclouds.abiquo.predicates.config.PrivilegePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
/**
* Live tests for the {@link ListPrivilegesImpl} strategy.
*
* @author Ignasi Barrera
*/
@Test(groups = "api", testName = "ListPrivilegesImplLiveApiTest")
public class ListPrivilegesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListPrivilegesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListPrivilegesImpl.class);
}
public void testExecute() {
Iterable<Privilege> privileges = strategy.execute();
assertNotNull(privileges);
assertTrue(size(privileges) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<Privilege> privileges = strategy.execute(PrivilegePredicates.name("Destroy the universe"));
assertNotNull(privileges);
assertEquals(size(privileges), 0);
}
public void testExecutePredicateWithResults() {
Iterable<Privilege> privileges = strategy.execute(PrivilegePredicates.name("USERS_MANAGE_USERS"));
assertNotNull(privileges);
assertEquals(size(privileges), 1);
}
public void testExecuteNotPredicateWithResults() {
Iterable<Privilege> privileges = strategy.execute(Predicates.not(PrivilegePredicates.name("USERS_MANAGE_USERS")));
Iterable<Privilege> allPrivileges = strategy.execute();
assertNotNull(privileges);
assertNotNull(allPrivileges);
assertEquals(size(privileges), size(allPrivileges) - 1);
}
}

View File

@ -1,89 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.config.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.config.SystemProperty;
import org.jclouds.abiquo.domain.config.options.PropertyOptions;
import org.jclouds.abiquo.predicates.config.SystemPropertyPredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
/**
* Live tests for the {@link ListPropertiesImpl} strategy.
*
* @author Ignasi Barrera
* @author Francesc Montserrat
*/
@Test(groups = "api", testName = "ListPropertiesImplLiveApiTest")
public class ListPropertiesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListPropertiesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListPropertiesImpl.class);
}
public void testExecute() {
Iterable<SystemProperty> properties = strategy.execute();
assertNotNull(properties);
assertTrue(size(properties) > 0);
}
public void testExecuteWithOptions() {
PropertyOptions options = PropertyOptions.builder().component("client").build();
Iterable<SystemProperty> properties = strategy.execute(options);
assertNotNull(properties);
assertTrue(size(properties) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<SystemProperty> properties = strategy.execute(SystemPropertyPredicates.name("Cloud color"));
assertNotNull(properties);
assertEquals(size(properties), 0);
}
public void testExecutePredicateWithResults() {
Iterable<SystemProperty> properties = strategy.execute(SystemPropertyPredicates
.name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval"));
assertNotNull(properties);
assertEquals(size(properties), 1);
}
public void testExecuteNotPredicateWithResults() {
Iterable<SystemProperty> properties = strategy.execute(Predicates.not(SystemPropertyPredicates
.name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval")));
Iterable<SystemProperty> allProperties = strategy.execute();
assertNotNull(properties);
assertNotNull(allProperties);
assertEquals(size(properties), size(allProperties) - 1);
}
}

View File

@ -1,65 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.enterprise.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.enterprise.Enterprise;
import org.jclouds.abiquo.predicates.enterprise.EnterprisePredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Live tests for the {@link ListEnterprisesImpl} strategy.
*
* @author Ignasi Barrera
*/
@Test(groups = "api", testName = "ListEnterprisesImplLiveApiTest")
public class ListEnterprisesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListEnterprisesImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListEnterprisesImpl.class);
}
public void testExecute() {
Iterable<Enterprise> enterprises = strategy.execute();
assertNotNull(enterprises);
assertTrue(size(enterprises) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<Enterprise> enterprises = strategy.execute(EnterprisePredicates.name("UNEXISTING"));
assertNotNull(enterprises);
assertEquals(size(enterprises), 0);
}
public void testExecutePredicateWithResults() {
Iterable<Enterprise> enterprises = strategy.execute(EnterprisePredicates.name(env.enterprise.getName()));
assertNotNull(enterprises);
assertEquals(size(enterprises), 1);
}
}

View File

@ -1,65 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.abiquo.strategy.infrastructure.internal;
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.assertTrue;
import org.jclouds.abiquo.domain.infrastructure.Datacenter;
import org.jclouds.abiquo.predicates.infrastructure.DatacenterPredicates;
import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Live tests for the {@link ListDatacentersImpl} strategy.
*
* @author Ignasi Barrera
*/
@Test(groups = "api", testName = "ListDatacentersImplLiveApiTest")
public class ListDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest {
private ListDatacentersImpl strategy;
@Override
@BeforeClass(groups = "api")
protected void setupStrategy() {
this.strategy = env.context.getUtils().getInjector().getInstance(ListDatacentersImpl.class);
}
public void testExecute() {
Iterable<Datacenter> datacenters = strategy.execute();
assertNotNull(datacenters);
assertTrue(size(datacenters) > 0);
}
public void testExecutePredicateWithoutResults() {
Iterable<Datacenter> datacenters = strategy.execute(DatacenterPredicates.name("UNEXISTING"));
assertNotNull(datacenters);
assertEquals(size(datacenters), 0);
}
public void testExecutePredicateWithResults() {
Iterable<Datacenter> datacenters = strategy.execute(DatacenterPredicates.name(env.datacenter.getName()));
assertNotNull(datacenters);
assertEquals(size(datacenters), 1);
}
}