### Question:
MapperFactory { public BaseMapper getMapperForField(String mappingType) { BaseMapper mapper = null; switch (mappingType) { case SubmissionFormFieldMappingType.COMPONENT: mapper = new ComponentFieldMapper(); break; case SubmissionFormFieldMappingType.COMPLEX: mapper = new ComplexMapper(); break; case SubmissionFormFieldMappingType.SUBMISSION: mapper = new SubmissionMapper(); break; case SubmissionFormFieldMappingType.NONE: mapper = new BaseMapper() { @Override public List<ComponentAll> mapField(ComponentAll componentAll, SubmissionFormField submissionField) { return new ArrayList<>(); } @Override public List<ComponentAll> mapField(ComponentAll componentAll, SubmissionFormField submissionField, UserSubmissionField userSubmissionField) { return new ArrayList<>(); } @Override public UserSubmissionFieldMedia mapComponentToSubmission(SubmissionFormField submissionField, ComponentFormSet componentFormSet, SubmissionFormTemplate template) throws MappingException { return null; } }; break; default: throw new UnsupportedOperationException(mappingType + " not supported"); } return mapper; }  BaseMapper getMapperForField(String mappingType);  }### Answer:
@Test public void testGetMapperForField() { System.out.println("getMapperForField: " + mappingType); MapperFactory instance = new MapperFactory(); BaseMapper result = instance.getMapperForField(mappingType); if (!expectedClass.isInstance(result)) { fail("Mapping didn't create expected class"); } }
@Test(expected = UnsupportedOperationException.class) public void testGetMapperForFieldBad() { System.out.println("getMapperForField: BAD"); MapperFactory instance = new MapperFactory(); instance.getMapperForField("BAD"); }