/*
 * Copyright (C) 2016 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.
 */
package com.google.copybara.testing;

import com.google.common.collect.ImmutableSetMultimap;
import com.google.copybara.Change;
import com.google.copybara.Changes;
import com.google.copybara.DestinationReader;
import com.google.copybara.Endpoint;
import com.google.copybara.LazyResourceLoader;
import com.google.copybara.Metadata;
import com.google.copybara.MigrationInfo;
import com.google.copybara.TransformWork;
import com.google.copybara.authoring.Author;
import com.google.copybara.util.console.Console;
import java.nio.file.Path;
import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * Utility methods related to {@link TransformWork}.
 */
public class TransformWorks {

  /**
   * A {@link Changes} object with no changes inside.
   */
  public static final Changes EMPTY_CHANGES = Changes.EMPTY;

  /**
   * Creates an instance with reasonable defaults for testing.
   */
  public static TransformWork of(Path checkoutDir, String msg, Console console) {
    return new TransformWork(
        checkoutDir,
        new Metadata(msg, new Author("foo", "foo@foo.com"), ImmutableSetMultimap.of()),
        Changes.EMPTY,
        console,
        new MigrationInfo(DummyOrigin.LABEL_NAME, /* destinationVisitable= */ null),
        new DummyRevision("1234567890"),
        /*ignoreNoop=*/ false, c -> new DummyEndpoint(), c -> new DummyEndpoint(),
        () -> DestinationReader.NOT_IMPLEMENTED);
  }

  /**
   * Creates an instance with reasonable defaults for testing.
   */
  public static TransformWork of(Path checkoutDir, String msg, Console console,
      LazyResourceLoader<Endpoint> originApi,  LazyResourceLoader<Endpoint> destinationApi) {
    return new TransformWork(
        checkoutDir,
        new Metadata(msg, new Author("foo", "foo@foo.com"), ImmutableSetMultimap.of()),
        Changes.EMPTY,
        console,
        new MigrationInfo(DummyOrigin.LABEL_NAME, /* destinationVisitable= */ null),
        new DummyRevision("1234567890"),
        /*ignoreNoop=*/ false, originApi, destinationApi,
        () -> DestinationReader.NOT_IMPLEMENTED);
  }


  public static Change<DummyRevision> toChange(DummyRevision dummyRevision, Author author) {
    return new Change<>(
        dummyRevision,
        author,
        dummyRevision.getMessage(),
        ZonedDateTime.now(ZoneId.systemDefault()),
        dummyRevision.getLabels(),
        /*changeFiles=*/ null);
  }
}

@@ -1555,24 +1555,281 @@
  console) %7B%0A
+    return of(checkoutDir, msg, console, false);%0A  %7D%0A%0A  /**%0A   * Creates an instance with reasonable defaults for testing and setting of ignoreNoop.%0A   */%0A  public static TransformWork of(Path checkoutDir, String msg, Console console, boolean ignoreNoop) %7B%0A
     return n
@@ -2121,34 +2121,32 @@
 7890%22),%0A        
-/*
 ignoreNoop=*/ fa
@@ -2139,25 +2139,16 @@
 noreNoop
-=*/ false
 , c -%3E n

Allow setting ignoreNoop in transformWork during test