Roll forward of https://github.com/bazelbuild/bazel/commit/5f31944b8942818aaf53571c76f5c6a9a9dafc72: Custom module map for j2objc_library

Automated g4 rollback of commit e7fe50aa727df9ef0a3d37fa258d017971035515.

*** Reason for rollback ***

Roll forward. The bzl change is removed because it has to be submitted after next Blaze release.

*** Original change description ***

Automated g4 rollback of commit 5f31944b8942818aaf53571c76f5c6a9a9dafc72.

*** Reason for rollback ***

This caused some build breaks.

*** Original change description ***

Custom module map for j2objc_library

PiperOrigin-RevId: 154726197
diff --git a/src/test/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunctionTest.java
index f19a31e..3215624 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunctionTest.java
@@ -1,4 +1,95 @@
-{
+// Copyright 2015 The Bazel Authors. All rights reserved.
+//
+// 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.devtools.build.lib.packages;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.packages.ImplicitOutputsFunction.AttributeValueGetter;
+import com.google.devtools.build.lib.testutil.Suite;
+import com.google.devtools.build.lib.testutil.TestSpec;
+import com.google.devtools.build.lib.util.Preconditions;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Tests for {@link ImplicitOutputsFunction}.
+ */
+@TestSpec(size = Suite.SMALL_TESTS)
+@RunWith(JUnit4.class)
+public final class ImplicitOutputsFunctionTest {
+  private void assertPlaceholderCollection(
+      String template, String expectedTemplate, String... expectedPlaceholders) throws Exception {
+    List<String> actualPlaceholders = new ArrayList<>();
+    assertEquals(
+        expectedTemplate,
+        ImplicitOutputsFunction.createPlaceholderSubstitutionFormatString(
+            template, actualPlaceholders));
+    assertThat(actualPlaceholders)
+        .containsExactlyElementsIn(Arrays.asList(expectedPlaceholders))
+        .inOrder();
+  }
+
+  @Test
+  public void testNoPlaceholder() throws Exception {
+    assertPlaceholderCollection("foo", "foo");
+  }
+
+  @Test
+  public void testJustPlaceholder() throws Exception {
+    assertPlaceholderCollection("%{foo}", "%s", "foo");
+  }
+
+  @Test
+  public void testPrefixedPlaceholder() throws Exception {
+    assertPlaceholderCollection("foo%{bar}", "foo%s", "bar");
+  }
+
+  @Test
+  public void testSuffixedPlaceholder() throws Exception {
+    assertPlaceholderCollection("%{foo}bar", "%sbar", "foo");
+  }
+
+  @Test
+  public void testMultiplePlaceholdersPrefixed() throws Exception {
+    assertPlaceholderCollection("foo%{bar}baz%{qux}", "foo%sbaz%s", "bar", "qux");
+  }
+
+  @Test
+  public void testMultiplePlaceholdersSuffixed() throws Exception {
+    assertPlaceholderCollection("%{foo}bar%{baz}qux", "%sbar%squx", "foo", "baz");
+  }
+
+  @Test
+  public void testTightlyPackedPlaceholders() throws Exception {
+    assertPlaceholderCollection("%{foo}%{bar}%{baz}", "%s%s%s", "foo", "bar", "baz");
+  }
+
+  @Test
+  public void testIncompletePlaceholder() throws Exception {
     assertPlaceholderCollection("%{foo", "%%{foo");
   }