package org.openstack.client.compute;

import org.openstack.client.AbstractOpenStackTest;
import org.openstack.client.OpenstackException;
import org.openstack.client.common.OpenstackComputeClient;
import org.openstack.client.utils.RandomUtil;
import org.testng.annotations.Test;

@Test
public class ComputeApiTest extends AbstractOpenStackTest {
	public OpenstackComputeClient getComputeClient() throws OpenstackException {
		return context.session.getComputeClient();
	}
}

@@ -215,31 +215,103 @@
 ack.
-client.utils.RandomUtil
+model.compute.Flavor;%0Aimport org.openstack.model.compute.Image;%0Aimport org.testng.SkipException
 ;%0Aim
@@ -538,9 +538,893 @@
 ();%0A
-
 %09%7D%0A
+%0A%09protected Flavor findSmallestFlavor() %7B%0A%09%09OpenstackComputeClient nova = getComputeClient();%0A%0A%09%09Flavor bestFlavor = null;%0A%09%09for (Flavor flavor : nova.root().flavors().list()) %7B%0A%09%09%09if (bestFlavor == null %7C%7C bestFlavor.getRam() %3E flavor.getRam()) %7B%0A%09%09%09%09bestFlavor = flavor;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return bestFlavor;%0A%09%7D%0A%0A%09protected Image findUecImage() %7B%0A%09%09OpenstackComputeClient nova = getComputeClient();%0A%0A%09%09Iterable%3CImage%3E images = nova.root().images().list();%0A%09%09for (Image i : images) %7B%0A%09%09%09// Some UEC images%0A%09%09%09if (i.getName().equals(%22lucid-server-cloudimg-amd64%22) %7C%7C i.getName().equals(%22natty-server-cloudimg-amd64%22)) %7B%0A%09%09%09%09return i;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%0A%09protected Image getUecImage() %7B%0A%09%09Image image = findUecImage();%0A%09%09if (image == null) %7B%0A%09%09%09throw new SkipException(%22Skipping test because image not found%22);%0A%09%09%7D%0A%0A%09%09System.out.println(%22Using image: %22 + image);%0A%0A%09%09return image;%0A%09%7D%0A%0A
 %7D%0A

Add some utility functions to ComputeApiTest