use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_insideIgnoreNoop.
@Test
public void testSequence_noopIfAnyNoop_insideIgnoreNoop() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.IGNORE_NOOP, sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1));
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_noChildNoops.
@Test
public void testSequence_noopIfAnyNoop_noChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1");
MockTransform t2 = new MockTransform("t2");
Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1, t2);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_failIfAnyNoop_causesFailure.
@Test
public void testSequence_failIfAnyNoop_causesFailure() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.FAIL_IF_ANY_NOOP, t1);
assertThrows(VoidOperationException.class, () -> t.transform(work));
assertThat(t1.wasRun).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_treeStateBeginsUncached.
/**
* A Sequence should automatically validate the cache in between each child Transformation that it
* runs.
*/
@Test
public void testSequence_treeStateBeginsUncached() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
// No cache for the first transform to use...
Transformation t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(false);
// ...but it should have created one for the second transform
Transformation t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(true);
Transformation t = sequence(t1, t2);
t.transform(work);
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_someChildNoops.
@Test
public void testSequence_noopIfAnyNoop_someChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1");
MockTransform t2 = new MockTransform("t2").setNoop(true);
MockTransform t3 = new MockTransform("t3");
Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1, t2, t3);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isFalse();
assertThat(status.isNoop()).isTrue();
}
Aggregations