mirror of https://github.com/apache/jclouds.git
Add GenerateUsageRecordsOptions + test
This commit is contained in:
parent
f5c9ba6c0a
commit
e64807ee59
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue