Source:
<code>private ICodeService createRemoteService() throws ProcessingException { ICodeService remoteService = Mockito.mock(ICodeService.class); when(remoteService.getAllCodeTypeClasses("")).thenReturn( CollectionUtility.hashSet( new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyRatingCodeType.class.getName()), new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyTypeCodeType.class.getName()) )); when(remoteService.getAllCodeTypeClasses(org.eclipse.scout.rt.client.Activator.PLUGIN_ID)).thenReturn( CollectionUtility.hashSet( new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyRatingCodeType.class.getName()), new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyTypeCodeType.class.getName()) )); when(remoteService.getCodeType(CompanyRatingCodeType.class)).thenReturn(new CompanyRatingCodeType()); when(remoteService.getCodeType(CompanyTypeCodeType.class)).thenReturn(new CompanyTypeCodeType()); when(remoteService.getCodeTypes(anyListOfCodeTypes())).thenAnswer(new Answer() { @Override <START> public Object answer(InvocationOnMock invocation) throws Throwable { <END> Object[] args = invocation.getArguments(); List<ICodeType<?, ?>> result = new ArrayList<ICodeType<?, ?>>(); @SuppressWarnings("unchecked") List<Class<? extends ICodeType<?, ?>>> list = (List<Class<? extends ICodeType<?, ?>>>) args[0]; for (Class<? extends ICodeType<?, ?>> codeTypeClass : list) { if (CompanyRatingCodeType.class.equals(codeTypeClass)) { result.add(new CompanyRatingCodeType()); } else if (CompanyTypeCodeType.class.equals(codeTypeClass)) { result.add(new CompanyTypeCodeType()); } else { fail("call of RemoteService#getCodeTypes(List) with a list containing an unexpected "); } } return result; } }); return remoteService; }</code><technical_language>do throw Throwable: throws ProcessingException</technical_language>

Target:
private static ICodeService createRemoteService() throws ProcessingException { ICodeService remoteService = Mockito.mock(ICodeService.class); when(remoteService.getAllCodeTypeClasses("")).thenReturn( CollectionUtility.hashSet( new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyRatingCodeType.class.getName()), new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyTypeCodeType.class.getName()) )); when(remoteService.getAllCodeTypeClasses(org.eclipse.scout.rt.client.Activator.PLUGIN_ID)).thenReturn( CollectionUtility.hashSet( new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyRatingCodeType.class.getName()), new BundleClassDescriptor(org.eclipse.scout.rt.client.Activator.PLUGIN_ID, CompanyTypeCodeType.class.getName()) )); when(remoteService.getCodeType(CompanyRatingCodeType.class)).thenReturn(new CompanyRatingCodeType()); when(remoteService.getCodeType(CompanyTypeCodeType.class)).thenReturn(new CompanyTypeCodeType()); when(remoteService.getCodeTypes(anyListOfCodeTypes())).thenAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws ProcessingException { Object[] args = invocation.getArguments(); List<ICodeType<?, ?>> result = new ArrayList<ICodeType<?, ?>>(); @SuppressWarnings("unchecked") List<Class<? extends ICodeType<?, ?>>> list = (List<Class<? extends ICodeType<?, ?>>>) args[0]; for (Class<? extends ICodeType<?, ?>> codeTypeClass : list) { if (CompanyRatingCodeType.class.equals(codeTypeClass)) { result.add(new CompanyRatingCodeType()); } else if (CompanyTypeCodeType.class.equals(codeTypeClass)) { result.add(new CompanyTypeCodeType()); } else { fail("call of RemoteService#getCodeTypes(List) with a list containing an unexpected "); } } return result; } }); return remoteService; }