### Question:
StringComplexFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static String replaceFirst(ReplaceFirst replaceFirst, String input) { if (replaceFirst == null || replaceFirst.getMatch() == null || replaceFirst.getMatch().isEmpty()) { throw new IllegalArgumentException("ReplaceFirst action must be specified with a non-empty old string"); } String match = replaceFirst.getMatch(); String newString = replaceFirst.getNewString(); return input == null ? null : input.replaceFirst(match, newString == null ? "" : newString); }  @AtlasActionProcessor static String append(Append append, String input); @AtlasActionProcessor(sourceType = FieldType.ANY) static String concatenate(Concatenate concat, List<String> inputs); @AtlasActionProcessor static Boolean endsWith(EndsWith endsWith, String input); @AtlasActionProcessor static String format(Format format, List<Object> input); @AtlasActionProcessor static String genareteUUID(GenerateUUID action); @AtlasActionProcessor static Number indexOf(IndexOf indexOf, String input); @AtlasActionProcessor static Number lastIndexOf(LastIndexOf lastIndexOf, String input); @AtlasActionProcessor static String padStringRight(PadStringRight padStringRight, String input); @AtlasActionProcessor static String padStringLeft(PadStringLeft padStringLeft, String input); @AtlasActionProcessor static String prepend(Prepend action, String input); @AtlasActionProcessor static String replaceAll(ReplaceAll replaceAll, String input); @AtlasActionProcessor static String replaceFirst(ReplaceFirst replaceFirst, String input); @AtlasActionProcessor(sourceType = FieldType.ANY) static String[] split(Split split, String input); @AtlasActionProcessor(sourceType = FieldType.ANY) static String[] repeat(Repeat repeat, String input); @AtlasActionProcessor static Boolean startsWith(StartsWith startsWith, String input); @AtlasActionProcessor static String subString(SubString subString, String input); @AtlasActionProcessor static String subStringAfter(SubStringAfter subStringAfter, String input); @AtlasActionProcessor static String subStringBefore(SubStringBefore subStringBefore, String input); static final String STRING_SEPARATOR_REGEX; static final Pattern STRING_SEPARATOR_PATTERN; }### Answer:
@Test public void testReplaceFirst() { ReplaceFirst replaceFirst = new ReplaceFirst(); replaceFirst.setMatch(" "); assertNull(StringComplexFieldActions.replaceFirst(replaceFirst, null)); assertEquals("", StringComplexFieldActions.replaceFirst(replaceFirst, "")); assertEquals("test", StringComplexFieldActions.replaceFirst(replaceFirst, "test")); replaceFirst.setMatch("e"); assertEquals("tst", StringComplexFieldActions.replaceFirst(replaceFirst, "test")); replaceFirst.setMatch("t"); replaceFirst.setNewString("h"); assertEquals("hest", StringComplexFieldActions.replaceFirst(replaceFirst, "test")); replaceFirst.setMatch("is"); replaceFirst.setNewString("at"); assertEquals("That is a test", StringComplexFieldActions.replaceFirst(replaceFirst, "This is a test")); }
@Test(expected = IllegalArgumentException.class) public void testReplaceFirstEmptyMatch() { ReplaceFirst replaceFirst = new ReplaceFirst(); replaceFirst.setMatch(""); StringComplexFieldActions.replaceFirst(replaceFirst, " "); }
@Test(expected=IllegalArgumentException.class) public void testReplaceFirstNullAction() { StringComplexFieldActions.replaceFirst(null, null); }
@Test(expected = IllegalArgumentException.class) public void testReplaceFirstNullMatch() { ReplaceFirst replaceFirst = new ReplaceFirst(); StringComplexFieldActions.replaceFirst(replaceFirst, " "); }