Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 741dd7ad09123de734b9227ce769778cf295c304 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*******************************************************************************
 * Copyright (c) 2017 Red Hat, Inc.
 * Distributed under license by Red Hat, Inc. All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributor:
 *     Red Hat, Inc. - initial API and implementation
 ******************************************************************************/
package org.eclipse.linuxtools.docker.reddeer.condition;

import static org.junit.Assert.assertNotNull;

import org.apache.commons.lang.StringUtils;
import org.eclipse.linuxtools.docker.reddeer.ui.resources.DockerConnection;
import org.eclipse.reddeer.common.condition.AbstractWaitCondition;

/**
 * @author adietish@redhat.com
 */
public class ImageIsDeployedCondition extends AbstractWaitCondition {

	private String name;
	private DockerConnection connection;
	private String tag;

	public ImageIsDeployedCondition(String name, DockerConnection connection) {
		this(name, null, connection);
	}

	public ImageIsDeployedCondition(String name, String tag, DockerConnection connection) {
		assertNotNull(this.name = name);
		assertNotNull(this.connection = connection);
		this.tag = tag;
	}

	@Override
	public boolean test() {
		if (StringUtils.isBlank(tag)) {
			return connection.imageIsDeployed(name);
		} else {
			return connection.getImage(name, tag) != null;
		}
	}
}

Back to the top