### Question:
FilterCopier { public Filter copyFilter(Filter orig, String typeKey) { Source s = orig.srcForType(typeKey); Group g = orig.getFilterGroup().clone(); if (!orig.getTypeKey().equals(typeKey)) { updateFields(g, orig.getTypeKey(), typeKey); } Filter f = new Filter(orig.getName(), s, g, s.isActive()); f.setFilterDescription(orig.getFilterDescription()); f.getOtherSources().addAll(orig.getOtherSources()); return f; } FilterCopier(ColumnMappingController columnMappingController); Filter virtualFilter(Filter f, String typeKey); Filter copyFilter(Filter orig, String typeKey); Filter copyFilter(Filter orig);  }### Answer:
@Test public void testCopyFilter() { ColumnMappingControllerImpl columnMappingController = new ColumnMappingControllerImpl(null); columnMappingController.initialize(); FilterCopier copier = new FilterCopier(columnMappingController); Filter sourceFilter = newFilter(); sourceFilter.setFilterDescription("filter1"); DataTypeInfo targetDataType = new DefaultDataTypeInfo(null, null, "key2", "name2", "display2", true); sourceFilter.getOtherSources().add(Source.fromDataType(targetDataType)); Filter copiedFilter = copier.copyFilter(sourceFilter, targetDataType.getTypeKey()); Assert.assertEquals("filter1", copiedFilter.getFilterDescription()); Criteria criteria0 = copiedFilter.getFilterGroup().getCriteria().get(0); Assert.assertEquals("field1", criteria0.getField()); Assert.assertEquals(Conditional.EQ, criteria0.getComparisonOperator()); Assert.assertEquals("123", criteria0.getValue()); Criteria criteriaInner0 = copiedFilter.getFilterGroup().getStdGroups().get(0).getCriteria().get(0); Assert.assertEquals("field1", criteriaInner0.getField()); Assert.assertEquals(Conditional.EQ, criteriaInner0.getComparisonOperator()); Assert.assertEquals("124", criteriaInner0.getValue()); columnMappingController.addMapping("blah", "key1", "field1", false); columnMappingController.addMapping("blah", "key2", "field2", false); copiedFilter = copier.copyFilter(sourceFilter, targetDataType.getTypeKey()); criteria0 = copiedFilter.getFilterGroup().getCriteria().get(0); Assert.assertEquals("field2", criteria0.getField()); Assert.assertEquals(Conditional.EQ, criteria0.getComparisonOperator()); Assert.assertEquals("123", criteria0.getValue()); criteriaInner0 = copiedFilter.getFilterGroup().getStdGroups().get(0).getCriteria().get(0); Assert.assertEquals("field2", criteriaInner0.getField()); Assert.assertEquals(Conditional.EQ, criteriaInner0.getComparisonOperator()); Assert.assertEquals("124", criteriaInner0.getValue()); }