Add GenerateUsageRecordsOptions + test

This commit is contained in:
Richard Downer 2011-12-16 15:17:27 +00:00
parent f5c9ba6c0a
commit e64807ee59
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,44 @@
/**
* 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.cloudstack.options;
import com.google.common.collect.ImmutableSet;
import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Options to the GlobalUsageClient.generateUsageOptions() API call
*
* @author Richard Downer
*/
public class GenerateUsageRecordsOptions extends BaseHttpRequestOptions {
public static final GenerateUsageRecordsOptions NONE = new GenerateUsageRecordsOptions();
public static class Builder {
public static GenerateUsageRecordsOptions domainId(long domainId) {
GenerateUsageRecordsOptions options = new GenerateUsageRecordsOptions();
return options.domainId(domainId);
}
}
public GenerateUsageRecordsOptions domainId(long domainId) {
this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + ""));
return this;
}
}

View File

@ -0,0 +1,44 @@
/**
* 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.cloudstack.options;
import com.google.common.collect.ImmutableSet;
import org.testng.annotations.Test;
import static org.jclouds.cloudstack.options.GenerateUsageRecordsOptions.Builder.domainId;
import static org.testng.Assert.assertEquals;
/**
* Tests behavior of {@code GenerateUsageRecordsOptions}
*
* @author Richard Downer
*/
@Test(groups = "unit")
public class GenerateUsageRecordsOptionsTest {
public void testDomainId() {
GenerateUsageRecordsOptions options = new GenerateUsageRecordsOptions().domainId(42);
assertEquals(ImmutableSet.of("42"), options.buildQueryParameters().get("domainid"));
}
public void testDomainIdStatic() {
GenerateUsageRecordsOptions options = domainId(42);
assertEquals(ImmutableSet.of("42"), options.buildQueryParameters().get("domainid"));
}
}