Search in sources :

Example 6 with ResourceOperationSpec

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.

the class ResourceOperationUtilsTest method testIsAvailable_changeContextFromScript.

@Test
public void testIsAvailable_changeContextFromScript() {
    ResourceOperationSpec spec = createResourceOperationSpec();
    spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".hostName='changed'";
    ComputeState computeState = createComputeState("testIsAvailable_changeContextFromScript");
    String originalValue = computeState.hostName;
    ResourceOperationUtils.isAvailable(computeState, spec);
    Assert.assertEquals(originalValue, computeState.hostName);
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BaseResourceOperationTest.createComputeState(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createComputeState) ResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec) BaseResourceOperationTest.createResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createResourceOperationSpec) Test(org.junit.Test)

Example 7 with ResourceOperationSpec

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.

the class ResourceOperationUtilsTest method testIsAvailable_custProps_neg.

@Test
public void testIsAvailable_custProps_neg() {
    ResourceOperationSpec spec = createResourceOperationSpec();
    spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".customProperties.p1=='v2'";
    ComputeState computeState = createComputeState("testIsAvailable_custProps_neg");
    boolean ret = ResourceOperationUtils.isAvailable(computeState, spec);
    Assert.assertFalse(ret);
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BaseResourceOperationTest.createComputeState(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createComputeState) ResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec) BaseResourceOperationTest.createResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createResourceOperationSpec) Test(org.junit.Test)

Example 8 with ResourceOperationSpec

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.

the class ResourceOperationUtilsTest method testIsAvailable_custProps_pos.

@Test
public void testIsAvailable_custProps_pos() {
    ResourceOperationSpec spec = createResourceOperationSpec();
    spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".customProperties.p1=='v1'";
    ComputeState computeState = createComputeState("testIsAvailable_custProps_pos");
    boolean ret = ResourceOperationUtils.isAvailable(computeState, spec);
    Assert.assertTrue(ret);
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BaseResourceOperationTest.createComputeState(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createComputeState) ResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec) BaseResourceOperationTest.createResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createResourceOperationSpec) Test(org.junit.Test)

Example 9 with ResourceOperationSpec

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.

the class ResourceOperationUtilsTest method testIsAvailable_noComputeState_pos.

@Test
public void testIsAvailable_noComputeState_pos() {
    ResourceOperationSpec spec = createResourceOperationSpec();
    spec.targetCriteria = "true";
    ResourceOperationUtils.isAvailable(null, spec);
}
Also used : ResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec) BaseResourceOperationTest.createResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createResourceOperationSpec) Test(org.junit.Test)

Example 10 with ResourceOperationSpec

use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.

the class BaseResourceOperationTest method createResourceOperationSpec.

protected ResourceOperationSpec createResourceOperationSpec(String endpointType, ResourceType resourceType, String operation) {
    ResourceOperationSpec roSpec = new ResourceOperationSpec();
    roSpec.endpointType = endpointType;
    roSpec.operation = operation;
    roSpec.name = operation;
    roSpec.description = operation;
    roSpec.resourceType = resourceType;
    roSpec.adapterReference = UriUtils.buildUri(this.host, ResourceOperationSpecService.buildDefaultAdapterLink(roSpec.endpointType, roSpec.resourceType, roSpec.operation));
    return roSpec;
}
Also used : ResourceOperationSpec(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec)

Aggregations

ResourceOperationSpec (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec)26 Test (org.junit.Test)14 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)10 BaseResourceOperationTest.createResourceOperationSpec (com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createResourceOperationSpec)7 BaseResourceOperationTest.createComputeState (com.vmware.photon.controller.model.adapters.registry.operations.BaseResourceOperationTest.createComputeState)6 Operation (com.vmware.xenon.common.Operation)4 List (java.util.List)3 QueryTop (com.vmware.photon.controller.model.query.QueryUtils.QueryTop)2 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)2 Query (com.vmware.xenon.services.common.QueryTask.Query)2 URI (java.net.URI)2 TypeToken (com.google.gson.reflect.TypeToken)1 ResourceType (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceType)1 Schema (com.vmware.photon.controller.model.data.Schema)1 SchemaBuilder (com.vmware.photon.controller.model.data.SchemaBuilder)1 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)1 ResourceState (com.vmware.photon.controller.model.resources.ResourceState)1 AssertUtil (com.vmware.photon.controller.model.util.AssertUtil)1 ClusterUtil (com.vmware.photon.controller.model.util.ClusterUtil)1 SELF_SERVICE (com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster.SELF_SERVICE)1