EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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