Reference { public static Reference valueOf(String serialized) { if (serialized.indexOf('@') < 1 || serialized.indexOf('@') >= (serialized.length() - 1)) { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity("Invalid reference") .build() ); } String entitySlug = StringUtils.substringBefore(serialized, "@"); String tenantSlug = StringUtils.substringAfter(serialized, "@"); return new Reference(entitySlug, tenantSlug); } Reference(String slug, String tenantSlug); String getEntitySlug(); String getTenantSlug(); static Reference valueOf(String serialized);  }
@Test(expected = WebApplicationException.class) public void testDeserializeInvalidReference1() { Reference.valueOf("@tenant"); }
@Test(expected = WebApplicationException.class) public void testDeserializeInvalidReference2() { Reference.valueOf("entity@"); }
@Test(expected = WebApplicationException.class) public void testDeserializeInvalidReference3() { Reference.valueOf("@"); }
@Test(expected = WebApplicationException.class) public void testDeserializeInvalidReference4() { Reference.valueOf("entity"); }