RESTUtils { public static <T, U> Response checkNullableEntitiesAndRemap(T entity, U entity2, BiFunction<T, U, ?> remapFunction) { if (entity != null && entity2 != null) { return okWithEntity(remapFunction.apply(entity, entity2)); } else { return notFound(); } }  static Response created(Class<?> resource, Long id); static Response checkEntityAndUpdate(T entity, Consumer<T> propsUpdate); static Response checkNullableEntitiesAndRemap(T entity, U entity2,
                                                                BiFunction<T, U, ?> remapFunction); static Response checkNullableEntityAndRemap(T entity, Function<T, Q> remapFunction); static Response checkNullableEntityAndReturn(T entity, Function<T, List<?>> then); static Response responseForNullableEntity(Object entity);  }
@Test public void checkNullableEntitiesAndRemapTest() { Response response = RESTUtils.checkNullableEntitiesAndRemap(1l, null, (a, b) -> ""); assertEquals(404, response.getStatus()); response = RESTUtils.checkNullableEntitiesAndRemap(null, "", (a, b) -> ""); assertEquals(404, response.getStatus()); response = RESTUtils.checkNullableEntitiesAndRemap("", "", (a, b) -> "ENTITY"); assertEquals(200, response.getStatus()); assertEquals("ENTITY", response.getEntity()); }