@Test
  public void testDeployWithInvalidEntityType() {
    try {
      clientDeploy(
          ApplicationSpec.builder()
              .name("invalid-app")
              .entities(ImmutableSet.of(new EntitySpec("invalid-ent", "not.existing.entity")))
              .locations(ImmutableSet.of("localhost"))
              .build());

    } catch (UniformInterfaceException e) {
      ApiError error = e.getResponse().getEntity(ApiError.class);
      assertEquals(error.getMessage(), "Undefined type 'not.existing.entity'");
    }
  }
  @Test
  public void testDeployWithInvalidLocation() {
    try {
      clientDeploy(
          ApplicationSpec.builder()
              .name("invalid-app")
              .entities(
                  ImmutableSet.of(
                      new EntitySpec("simple-ent", RestMockSimpleEntity.class.getName())))
              .locations(ImmutableSet.of("3423"))
              .build());

    } catch (UniformInterfaceException e) {
      ApiError error = e.getResponse().getEntity(ApiError.class);
      assertEquals(error.getMessage(), "Undefined location '3423'");
    }
  }
Exemplo n.º 3
0
 public static WebApplicationException preconditionFailed(String format, Object... args) {
   String msg = String.format(format, args);
   if (log.isDebugEnabled()) log.debug("returning 412 preconditionFailed(" + msg + ")");
   throw new WebApplicationException(
       Response.status(Response.Status.PRECONDITION_FAILED)
           .type(MediaType.APPLICATION_JSON_TYPE)
           .entity(ApiError.builder().message(msg).build())
           .build());
 }
Exemplo n.º 4
0
 public static WebApplicationException notFound(String format, Object... args) {
   String msg = String.format(format, args);
   if (log.isDebugEnabled())
     log.debug("returning 404 notFound(" + msg + ") - may be a stale browser session");
   throw new WebApplicationException(
       Response.status(Response.Status.NOT_FOUND)
           .type(MediaType.APPLICATION_JSON_TYPE)
           .entity(ApiError.builder().message(msg).build())
           .build());
 }