AttributeHelper { public void extractNameParts(Attribute attrib, AssertionType assertOut) { LOG.debug("Entering AttributeHelper.extractNameParts..."); List<XMLObject> attrVals = attrib.getAttributeValues(); if (CollectionUtils.isNotEmpty(attrVals)) { PersonNameType personName = assertOut.getUserInfo().getPersonName(); String completeName = extractAttributeValueString(attrib); personName.setFullName(completeName); LOG.trace("Assertion.userInfo.personName.FullName = {}", completeName); String[] nameTokens = completeName.split("\\s"); ArrayList<String> nameParts = new ArrayList<>(); for (String tok : nameTokens) { if (tok.trim() != null && tok.trim().length() > 0) { nameParts.add(tok.trim()); } } removeTokens(nameParts, personName); } else { LOG.error("User Name attribute is empty: {}", attrVals); } LOG.debug("AttributeHelper.extractNameParts() -- End"); }  CeType extractNhinCodedElement(Attribute attrib, String codeId); String extractAttributeValueString(Attribute attrib); void extractNameParts(Attribute attrib, AssertionType assertOut);  }
@Test public final void testExtractNameParts() { Attribute attrib = mock(Attribute.class); List<XMLObject> attrVals = new ArrayList<>(); XSStringImpl mockStringValue = mock(XSStringImpl.class); when(mockStringValue.getValue()).thenReturn("ONC Team"); attrVals.add(mockStringValue); when(attrib.getAttributeValues()).thenReturn(attrVals); AssertionType assertOut = mock(AssertionType.class); PersonNameType mockPersonNameType = new PersonNameType(); UserType userType = new UserType(); userType.setPersonName(mockPersonNameType); when(assertOut.getUserInfo()).thenReturn(userType); helper.extractNameParts(attrib, assertOut); PersonNameType result = assertOut.getUserInfo().getPersonName(); Assert.assertEquals("ONC Team", result.getFullName()); }