EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.savvis.vpdc.binders]

COVERAGE SUMMARY FOR SOURCE FILE [BindVMSpecsToXmlPayload.java]

nameclass, %method, %block, %line, %
BindVMSpecsToXmlPayload.java100% (1/1)100% (3/3)91%  (63/69)93%  (13.9/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BindVMSpecsToXmlPayload100% (1/1)100% (3/3)91%  (63/69)93%  (13.9/15)
findSpecInArgsOrNull (GeneratedHttpRequest): Iterable 100% (1/1)81%  (26/32)82%  (4.9/6)
BindVMSpecsToXmlPayload (): void 100% (1/1)100% (3/3)100% (1/1)
bindSpec (Iterable, XMLBuilder): void 100% (1/1)100% (34/34)100% (8/8)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.savvis.vpdc.binders;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import javax.inject.Singleton;
24import javax.xml.parsers.FactoryConfigurationError;
25import javax.xml.parsers.ParserConfigurationException;
26 
27import org.jclouds.rest.internal.GeneratedHttpRequest;
28import org.jclouds.savvis.vpdc.domain.VMSpec;
29 
30import com.google.common.collect.Iterables;
31import com.jamesmurty.utils.XMLBuilder;
32 
33/**
34 * 
35 * @author Adrian Cole
36 * 
37 */
38@Singleton
39public class BindVMSpecsToXmlPayload extends BaseBindVMSpecToXmlPayload<Iterable<VMSpec>> {
40 
41   @SuppressWarnings("unchecked")
42   protected Iterable<VMSpec> findSpecInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
43      for (Object arg : gRequest.getArgs()) {
44         if (arg instanceof Iterable<?>) {
45            Iterable<VMSpec> specs = (Iterable<VMSpec>) arg;
46            checkArgument(Iterables.size(specs) > 0,
47                     "At least one VMSpec must be included in the argument list");
48            return specs;
49         }
50      }
51      throw new IllegalArgumentException("Iterbable<VMSpec> must be included in the argument list");
52   }
53 
54   @Override
55   protected void bindSpec(Iterable<VMSpec> specs, XMLBuilder rootBuilder) throws ParserConfigurationException, FactoryConfigurationError {
56      rootBuilder.a("name", "");
57      XMLBuilder specBuilder = buildChildren(rootBuilder);
58      for (VMSpec spec : specs) {
59         checkSpec(spec);
60         XMLBuilder vAppBuilder = buildRootForName(specBuilder, spec.getName());
61         addOperatingSystemAndVirtualHardware(spec, vAppBuilder);
62      }
63   }
64}

[all classes][org.jclouds.savvis.vpdc.binders]
EMMA 2.0.5312 (C) Vladimir Roubtsov