### Question:
AdWordsAxisSoapHeaderFactory implements AxisSoapHeaderFactory<AdWordsServiceDescriptor> { @Override public Object createSoapHeader(AdWordsServiceDescriptor adWordsServiceDescriptor) throws InvocationTargetException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException { Class<?> interfaceClass = adWordsServiceDescriptor.getInterfaceClass(); String packageName = interfaceClass.getPackage().getName(); List<String> packageParts = Lists.newArrayList(packageName.split("\\.")); String parentPackage = Joiner.on(".").join(packageParts.subList(0, packageParts.size() - 1)); Constructor<?> constructor = Class.forName(parentPackage + "." + headerPartialName).getDeclaredConstructor(); return constructor.newInstance(); } @Inject  AdWordsAxisSoapHeaderFactory(); @VisibleForTesting  AdWordsAxisSoapHeaderFactory(String headerPartialName); @Override Object createSoapHeader(AdWordsServiceDescriptor adWordsServiceDescriptor);  }### Answer:
@Test public void testCreateHeader() throws Exception { doReturn(interfaceClass).when(adWordsServiceDescriptor).getInterfaceClass(); Object soapHeader = headerFactory.createSoapHeader(adWordsServiceDescriptor); assertEquals( "Factory did not create an instance of the expected type", headerClass, soapHeader.getClass()); }