1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package utils.resources; 17 18 /** 19 * An interface which represents a resource to be used in a test case. 20 * <p> 21 * Note that sub-classes implementing this interface must provide a no-arg 22 * constructor. 23 */ 24 public interface TestResource { 25 26 /** 27 * Create/initialize the resource which this TestResource represents. 28 * 29 * @param waitTillFinished Whether this method should block until the resource is fully 30 * initialized. 31 */ create(boolean waitTillFinished)32 void create(boolean waitTillFinished); 33 34 /** 35 * Delete the resource which this TestResource represents. 36 * 37 * @param waitTillFinished Whether this method should block until the resource is fully 38 * initialized. 39 */ delete(boolean waitTillFinished)40 void delete(boolean waitTillFinished); 41 42 /** 43 * Returns the current status of the resource which this TestResource 44 * represents. 45 */ getResourceStatus()46 ResourceStatus getResourceStatus(); 47 48 /** 49 * Enum of all the generalized resource statuses. 50 */ 51 enum ResourceStatus { 52 /** 53 * The resource is currently available, and it is compatible with the 54 * required resource. 55 */ 56 AVAILABLE, 57 /** 58 * The resource does not exist and there is no existing resource that is 59 * incompatible. 60 */ 61 NOT_EXIST, 62 /** 63 * There is an existing resource that has to be removed before creating 64 * the required resource. For example, DDB table with the same name but 65 * different table schema. 66 */ 67 EXIST_INCOMPATIBLE_RESOURCE, 68 /** 69 * The resource is in transient state (e.g. creating/deleting/updating) 70 */ 71 TRANSIENT, 72 } 73 } 74