### Question:
MappingController { public ValidationResult verifyTemplate(SubmissionFormTemplate template, String componentType) { Objects.requireNonNull(template); ValidationResult result = new ValidationResult(); ComponentFormSet componentFormSet = new ComponentFormSet(); ComponentAll mainComponent = new ComponentAll(); Component component = new Component(); component.setComponentType(componentType); component.setApprovalState(ApprovalStatus.NOT_SUBMITTED); mainComponent.setComponent(component); componentFormSet.setPrimary(mainComponent); try { verifySections(template, componentFormSet); } catch (MappingException ex) { LOG.log(Level.FINER, "Verified failed; Details", ex); RuleResult ruleResult = new RuleResult(); ruleResult.setFieldName(ex.getFieldType()); ruleResult.setMessage(ex.getLocalizedMessage()); result.getRuleResults().add(ruleResult); } result.merge(componentFormSet.validate(false)); return result; } MappingController();  MappingController(MapperFactory mapperFactory); ValidationResult verifyTemplate(SubmissionFormTemplate template, String componentType); ComponentFormSet mapUserSubmissionToEntry(SubmissionFormTemplate template, UserSubmission userSubmission); UserSubmissionAll mapEntriesToUserSubmission(SubmissionFormTemplate template, ComponentFormSet componentFormSet);  }### Answer:
@Test public void testVerifyTemplateWithSectionsInvalid() { setupMockService(); SubmissionFormTemplate template = new SubmissionFormTemplate(); template.setSections(new ArrayList<>()); template.getSections().add(new SubmissionFormSection()); MapperFactory mockMapperFactory = getMockMapperFactory(); MappingController instance = new MappingController(mockMapperFactory); ValidationResult result = instance.verifyTemplate(template, TEST); assertFalse(result.valid()); }
@Test(expected = NullPointerException.class) public void testVerifyTemplateNullTemplate() { MappingController instance = new MappingController(); instance.verifyTemplate(null, "Test"); }
@Test public void testVerifyTemplateWithoutSectionsInvalid() { setupMockService(); SubmissionFormTemplate template = new SubmissionFormTemplate(); MapperFactory mockMapperFactory = getMockMapperFactory(); MappingController instance = new MappingController(mockMapperFactory); ValidationResult result = instance.verifyTemplate(template, TEST); assertFalse(result.valid()); }
@Test public void testVerifyTemplateWithFieldsInvalid() { setupMockService(); SubmissionFormTemplate template = new SubmissionFormTemplate(); template.setSections(new ArrayList<>()); SubmissionFormSection section = new SubmissionFormSection(); section.setFields(new ArrayList<>()); SubmissionFormField submissionFormField = new SubmissionFormField(); submissionFormField.setMappingType(SubmissionFormFieldMappingType.COMPONENT); section.getFields().add(submissionFormField); template.getSections().add(new SubmissionFormSection()); MapperFactory mockMapperFactory = getMockMapperFactory(); MappingController instance = new MappingController(mockMapperFactory); ValidationResult result = instance.verifyTemplate(template, TEST); assertFalse(result.valid()); }
@Test public void testVerifyTemplateWithFieldsValid() { setupMockService(); SubmissionFormTemplate template = new SubmissionFormTemplate(); template.setSections(new ArrayList<>()); SubmissionFormSection section = new SubmissionFormSection(); section.setFields(new ArrayList<>()); SubmissionFormField submissionFormField = new SubmissionFormField(); submissionFormField.setMappingType(SubmissionFormFieldMappingType.COMPONENT); submissionFormField.setFieldName(Component.FIELD_NAME); section.getFields().add(submissionFormField); submissionFormField = new SubmissionFormField(); submissionFormField.setMappingType(SubmissionFormFieldMappingType.COMPONENT); submissionFormField.setFieldName(Component.FIELD_ORGANIZATION); section.getFields().add(submissionFormField); submissionFormField = new SubmissionFormField(); submissionFormField.setMappingType(SubmissionFormFieldMappingType.COMPONENT); submissionFormField.setFieldName(Component.FIELD_DESCRIPTION); section.getFields().add(submissionFormField); template.getSections().add(section); MappingController instance = new MappingController(); ValidationResult result = instance.verifyTemplate(template, TEST); assertTrue(result.valid()); }