-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jeffrey Kinard <jeff@thekinards.com>
- Loading branch information
Showing
22 changed files
with
1,491 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright (C) 2023 Google Inc. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
~ use this file except in compliance with the License. You may obtain a copy of | ||
~ the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
~ License for the specific language governing permissions and limitations under | ||
~ the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.google.cloud.teleport</groupId> | ||
<artifactId>integration-testing-lib</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>it-conditions</artifactId> | ||
|
||
<properties> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.beam</groupId> | ||
<artifactId>beam-it-conditions</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.value</groupId> | ||
<artifactId>auto-value</artifactId> | ||
<version>${autovalue.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.value</groupId> | ||
<artifactId>auto-value-annotations</artifactId> | ||
<version>${autovalue.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
74 changes: 74 additions & 0 deletions
74
it/conditions/src/main/java/org/apache/beam/it/conditions/ChainedConditionCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.beam.it.conditions; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import java.util.List; | ||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The ChainedConditionCheck class provides a base interface for chaining {@link ConditionCheck} | ||
* checks. Each subsequent check will wait on the previous check to complete and return true. | ||
*/ | ||
@AutoValue | ||
public abstract class ChainedConditionCheck extends ConditionCheck { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ChainedConditionCheck.class); | ||
|
||
private int functionIndex = 0; | ||
|
||
abstract List<ConditionCheck> conditionChecks(); | ||
|
||
@Override | ||
public String getDescription() { | ||
return String.format( | ||
"Chained condition check %d/%d...", functionIndex + 1, conditionChecks().size()); | ||
} | ||
|
||
@Override | ||
public Boolean get() { | ||
LOG.info(getDescription()); | ||
if (conditionChecks().get(functionIndex).get()) { | ||
functionIndex++; | ||
} | ||
return functionIndex == conditionChecks().size(); | ||
} | ||
|
||
@Override | ||
protected CheckResult check() { | ||
throw new NotImplementedException("This check() should never be called."); | ||
} | ||
|
||
public static Builder builder(List<ConditionCheck> conditionChecks) { | ||
return new AutoValue_ChainedConditionCheck.Builder().setConditionChecks(conditionChecks); | ||
} | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
|
||
public abstract Builder setConditionChecks(List<ConditionCheck> setConditionChecks); | ||
|
||
abstract ChainedConditionCheck autoBuild(); | ||
|
||
public ChainedConditionCheck build() { | ||
return autoBuild(); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
it/conditions/src/main/java/org/apache/beam/it/conditions/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** Package for working with test artifacts. */ | ||
package org.apache.beam.it.conditions; |
Oops, something went wrong.