/*
 * 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.runners.core.construction;

import com.google.auto.service.AutoService;
import org.apache.beam.model.pipeline.v1.RunnerApi;
import org.apache.beam.runners.core.construction.NativeTransforms.IsNativeTransform;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link NativeTransforms}. */
@RunWith(JUnit4.class)
public class NativeTransformsTest {
  /** A test implementation of a {@link IsNativeTransform}. */
  @AutoService(IsNativeTransform.class)
  public static class TestNativeTransform implements IsNativeTransform {

    @Override
    public boolean test(RunnerApi.PTransform pTransform) {
      return "test".equals(PTransformTranslation.urnForTransformOrNull(pTransform));
    }
  }

  @Test
  public void testMatch() {
    NativeTransforms.isNative(
        RunnerApi.PTransform.newBuilder()
            .setSpec(RunnerApi.FunctionSpec.newBuilder().setUrn("test").build())
            .build());
  }

  @Test
  public void testNoMatch() {
    NativeTransforms.isNative(RunnerApi.PTransform.getDefaultInstance());
  }
}

@@ -1032,16 +1032,41 @@
 nsform;%0A
+import org.junit.Assert;%0A
 import o
@@ -1623,32 +1623,59 @@
 d testMatch() %7B%0A
+    Assert.assertTrue(%0A    
     NativeTransf
@@ -1697,16 +1697,20 @@
         
+   
+ 
 RunnerAp
@@ -1735,16 +1735,20 @@
 ilder()%0A
+    
         
@@ -1832,16 +1832,20 @@
         
+   
+ 
 .build()
@@ -1845,16 +1845,17 @@
 build())
+)
 ;%0A  %7D%0A%0A 
@@ -1891,24 +1891,43 @@
 tch() %7B%0A    
+Assert.assertFalse(
 NativeTransf
@@ -1982,16 +1982,17 @@
 tance())
+)
 ;%0A  %7D%0A%7D%0A

add NativeTransform test assertions