DefaultStringPatchMapping extends PatchMapping { @Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(isAddOrReplace(modelOperation), "You can only change the value of " + name); checkArgument(modelOperation.getValue() instanceof String, name + " must be a string"); checkArgument(StringUtils.isNotBlank((CharSequence) modelOperation.getValue()), name + " cannot be blank"); return PatchOperation.replace("/" + name, modelOperation.getValue()); } DefaultStringPatchMapping(String name); @Override String getPath(); @Override PatchOperation convertOperation(Road road, PatchOperation modelOperation);  }
@Test(expected = IllegalArgumentException.class) public void partitionPath_cannot_be_blank() throws Exception { mapping.convertOperation(road, PatchOperation.replace("/foo", " ")); }
@Test(expected = IllegalArgumentException.class) public void partitionPath_cannot_be_null() throws Exception { mapping.convertOperation(road, PatchOperation.replace("/foo", null)); }
@Test(expected = IllegalArgumentException.class) public void remove_patch_fails() throws Exception { mapping.convertOperation(road, PatchOperation.remove("/foo")); }
@Test(expected = IllegalArgumentException.class) public void setting_to_a_non_string_fails() throws Exception { mapping.convertOperation(road, PatchOperation.add("/foo", false)); }