State waitForDeployState(String resourceName, State... targetStates) {
		DeploymentUnitStatus.State currentState = deploymentStatusRepository.getDeploymentStatus(resourceName).getState();
		long waitTime = 0;
		List<State> targetStateList = Arrays.asList(targetStates);
		while (!targetStateList.contains(currentState) && waitTime < STATE_CHANGE_TIMEOUT) {
			try {
				Thread.sleep(STATE_CHANGE_WAIT_TIME);
				currentState = deploymentStatusRepository.getDeploymentStatus(resourceName).getState();
				waitTime += STATE_CHANGE_WAIT_TIME;
			}
			catch (InterruptedException e) {
				Thread.currentThread().interrupt();
			}
		}
		return currentState;
	}
Wait for the State to change to one or more expected target states.
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/test/ResourceStateVerifier.java