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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations