/**
 * Copyright (C) 2015 Red Hat, 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 io.fabric8.kubernetes.client.mock;

import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionNames;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import io.fabric8.kubernetes.client.mock.crd.FooBar;
import io.fabric8.kubernetes.client.mock.crd.FooBarList;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;

@EnableRuleMigrationSupport
class CustomResourceCrud1109Test {
  @Rule
  public KubernetesServer server = new KubernetesServer(true,true);

  private CustomResourceDefinition customResourceDefinition;

  @BeforeEach
  void setUp() {
    /*customResourceDefinition = server.getClient().apiextensions().v1beta1().customResourceDefinitions()
      .create(new CustomResourceDefinitionBuilder()
      .withNewMetadata()
      .withName("foo-bar.baz.example.com")
      .endMetadata()
      .withNewSpec()
      .withGroup("baz.example.com")
      .addNewVersion().withName("v1alpha1").endVersion()
      .withScope("Namespaced")
      .withNewNames()
      .withKind("FooBar")
      .withPlural("foo-bars")
      .withSingular("foo-bar")
      .endNames()
      .endSpec()
      .build());*/
    customResourceDefinition = server.getClient().apiextensions().v1beta1().customResourceDefinitions()
      .create(CustomResourceDefinitionContext.crdFromCustomResourceType(FooBar.class).build());
  }

  @Test
  @DisplayName("Fix for issue 1109, verifies resources with dashes can be retrieved")
  void test1109() {
    
    final CustomResourceDefinitionNames names = customResourceDefinition.getSpec().getNames();
    Assertions.assertEquals(FooBar.SINGULAR + "s", names.getPlural());
    Assertions.assertEquals(FooBar.SINGULAR, names.getSingular());
    Assertions.assertEquals("FooBar", names.getKind());
    Assertions.assertEquals("foo-bar.baz.example.com", customResourceDefinition.getMetadata().getName());
    Assertions.assertEquals(FooBar.VERSION, customResourceDefinition.getSpec().getVersion());
    
    // Given
    final MixedOperation<FooBar, FooBarList, Resource<FooBar>> fooBarClient = server.getClient().customResources(FooBar.class, FooBarList.class);
    final FooBar fb1 = new FooBar();
    fb1.getMetadata().setName("example");
    fooBarClient.inNamespace("default").create(fb1);
    final FooBarList list = fooBarClient.inNamespace("default").list();
    Assertions.assertEquals(1, list.getItems().size());
    Assertions.assertEquals("FooBar", list.getItems().iterator().next().getKind());
    // When
    final FooBar fooBar = fooBarClient.inNamespace("default").withName("example").get();
    // Then
    Assertions.assertNotNull(fooBar);
  }
}

@@ -1678,563 +1678,8 @@
 ) %7B%0A
-    /*customResourceDefinition = server.getClient().apiextensions().v1beta1().customResourceDefinitions()%0A      .create(new CustomResourceDefinitionBuilder()%0A      .withNewMetadata()%0A      .withName(%22foo-bar.baz.example.com%22)%0A      .endMetadata()%0A      .withNewSpec()%0A      .withGroup(%22baz.example.com%22)%0A      .addNewVersion().withName(%22v1alpha1%22).endVersion()%0A      .withScope(%22Namespaced%22)%0A      .withNewNames()%0A      .withKind(%22FooBar%22)%0A      .withPlural(%22foo-bars%22)%0A      .withSingular(%22foo-bar%22)%0A      .endNames()%0A      .endSpec()%0A      .build());*/%0A
     
@@ -1778,16 +1778,16 @@
 tions()%0A
+
       .c
@@ -2101,53 +2101,87 @@
     
-Assertions.assertEquals(FooBar.SINGULAR + %22s%22
+final String plural = FooBar.SINGULAR + %22s%22;%0A    Assertions.assertEquals(plural
 , na
@@ -2353,33 +2353,35 @@
 als(
-%22foo-bar.baz.example.com%22
+plural + %22.%22 + FooBar.GROUP
 , cu

wrong test assumption