### Question:
Formats { public static Format fromString(String formatName) { if (formatName.equals("avro")) { return AVRO; } else if (formatName.equals("parquet")) { return PARQUET; } else if (formatName.equals("json")) { return JSON; } else if (formatName.equals("csv")) { return CSV; } else if (formatName.equals("inputformat")) { return INPUTFORMAT; } else { throw new IllegalArgumentException("Unknown format type: " + formatName); } } private  Formats(); static Format fromString(String formatName); static final Format AVRO; static final Format PARQUET; static final Format JSON; static final Format CSV; static final Format INPUTFORMAT; }### Answer:
@Test public void testFromStringForValidFormats() { assertSame(Formats.AVRO, Formats.fromString("avro")); assertSame(Formats.PARQUET, Formats.fromString("parquet")); }
@Test(expected = IllegalArgumentException.class) public void testFromStringForInvalidFormats() { Formats.fromString("bogus"); }