/**
   * CustomerResource.createCustomer is annotated with @Produces({MediaType.APPLICATION_JSON,
   * MediaType.APPLICATION_XML}). This means that injected proxy by default will use first mime type
   * which in this case is JSON. To force proxy to use XML we annotate test method
   * with @Produces(MediaType.APPLICATION_XML). Arquillian scanns all CustomerResource methods and
   * substitutes annotations with those from this test method. CustomerResource is annotated also
   * with @POST and @Path which will remain, because they don't exist on this test method.
   *
   * @param customerResource configured resource ready for use, injected by Arquillian
   */
  @Test
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_XML)
  public void createCustomer(@ArquillianResteasyResource CustomerResource customerResource) {
    //        Given
    final String name = "Jack";

    //        When
    final Customer result = customerResource.createCustomer(new Customer(name));

    //        Then
    assertNotNull(result);
    assertNotNull(result.getId());
    assertEquals(name, result.getName());
  }
  // @Ignore("I do not know why this test is failing on Jersey (tomcat-embedded profile)")
  @Test
  public void getCustomerById(
      @ArquillianResteasyResource("rest") CustomerResource customerResource) {
    //        Given
    final String name = "Acme Corporation";
    final long customerId = 1L;

    //        When
    final Customer result = customerResource.getCustomerById(customerId);

    //        Then
    assertNotNull(result);
    assertNotNull(result.getId());
    assertEquals(name, result.getName());
  }
  /**
   * Totally manually created RestEasy client. This test shows what crazy thing you can do manually
   * with ClassModifier.
   *
   * @throws Exception well, test may throw exceptions from time to time
   */
  @Test
  public void manualClassModifierUsage() throws Exception {
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_XML)
    class A {}
    final Class<CustomerResource> aClass =
        ClassModifier.getModifiedClass(CustomerResource.class, A.class.getAnnotations());
    //        Given
    final String name = "Jack";
    final Customer customer = new Customer(name);
    Client client = JerseyClientBuilder.newClient();
    WebTarget webTarget = client.target(deploymentURL + "rest");
    JerseyWebTarget jerseyWebTarget = (JerseyWebTarget) webTarget;
    final CustomerResource customerResource =
        WebResourceFactory.newResource(aClass, jerseyWebTarget);

    //        When
    final Customer result = customerResource.createCustomer(customer);

    //        Then
    assertNotNull(result);
    assertNotNull(result.getId());
    assertEquals(name, result.getName());
  }