use of org.cytoscape.io.internal.read.transformer.CyTransformerReaderImpl in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method initMocks.
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
transformerContainer = new TestTransformerContainer();
TransformerManagerImpl transformerManager = new TransformerManagerImpl();
transformerManager.registerFilterFactory(new ColumnFilterFactory(), Collections.emptyMap());
transformerManager.registerFilterFactory(new DegreeFilterFactory(), Collections.emptyMap());
transformerManager.registerFilterFactory(new TopologyFilterFactory(), Collections.emptyMap());
transformerManager.registerFilterFactory(new CompositeFilterFactory<>(CyNetwork.class, CyIdentifiable.class), Collections.emptyMap());
CyTransformerReaderImpl transformerReader = new CyTransformerReaderImpl();
transformerReader.registerTransformerManager(transformerManager, Collections.emptyMap());
when(serviceRegistrar.getService(CyTransformerReader.class)).thenReturn(transformerReader);
when(serviceRegistrar.getService(TransformerContainer.class, "(container.type=filter)")).thenReturn(transformerContainer);
}
use of org.cytoscape.io.internal.read.transformer.CyTransformerReaderImpl in project cytoscape-impl by cytoscape.
the class FilterIOTest method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() throws Exception {
DegreeFilter degreeFilter = new DegreeFilter();
degreeFilter.setCriterion(new Double[] { 0.2, 5.5 });
degreeFilter.setEdgeType(CyEdge.Type.ANY);
DummyFilter dummyFilter = new DummyFilter();
CyTransformerWriter writer = new CyTransformerWriterImpl();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
writer.write(stream, FilterIO.createNamedTransformer("filter1", degreeFilter), FilterIO.createNamedTransformer("filter2", dummyFilter));
String serialized = stream.toString("utf-8");
TransformerManagerImpl transformerManager = new TransformerManagerImpl();
Map<String, String> properties = Collections.emptyMap();
transformerManager.registerFilterFactory(new DegreeFilterFactory(), properties);
transformerManager.registerFilterFactory(new DummyFilterFactory(), properties);
CyTransformerReaderImpl reader = new CyTransformerReaderImpl();
reader.registerTransformerManager(transformerManager, null);
ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
NamedTransformer<?, ?>[] transformers = reader.read(inputStream);
ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
writer.write(stream2, transformers);
String serialized2 = stream2.toString("utf-8");
Assert.assertEquals(serialized, serialized2);
}
use of org.cytoscape.io.internal.read.transformer.CyTransformerReaderImpl in project cytoscape-impl by cytoscape.
the class FilterIOTest method testSubFilterTransformerRoundTrip.
@SuppressWarnings("rawtypes")
@Test
public void testSubFilterTransformerRoundTrip() throws Exception {
ColumnFilter columnFilter = new ColumnFilter();
columnFilter.setColumnName("MyColName");
columnFilter.setPredicateAndCriterion(Predicate.CONTAINS, "blah");
AdjacencyTransformer adjacency = new AdjacencyTransformer();
adjacency.setAction(Action.REPLACE);
adjacency.setEdgesAre(EdgesAre.INCOMING);
adjacency.setFilterTarget(What.EDGES);
adjacency.setOutput(What.EDGES);
adjacency.getCompositeFilter().append(columnFilter);
CyTransformerWriter writer = new CyTransformerWriterImpl();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
writer.write(stream, FilterIO.createNamedTransformer("transformer1", adjacency));
// String serialized = stream.toString("utf-8");
TransformerManagerImpl transformerManager = new TransformerManagerImpl();
Map<String, String> properties = Collections.emptyMap();
transformerManager.registerFilterFactory(new ColumnFilterFactory(), properties);
transformerManager.registerElementTransformerFactory(new AdjacencyTransformerFactory(), properties);
CyTransformerReaderImpl reader = new CyTransformerReaderImpl();
reader.registerTransformerManager(transformerManager, null);
ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
NamedTransformer<?, ?>[] transformers = reader.read(inputStream);
Assert.assertNotNull(transformers);
Assert.assertEquals(1, transformers.length);
NamedTransformer<?, ?> namedTransformer = transformers[0];
Assert.assertNotNull(namedTransformer);
Assert.assertEquals("transformer1", namedTransformer.getName());
List children = namedTransformer.getTransformers();
Assert.assertEquals(1, children.size());
Transformer child = (Transformer) children.get(0);
Assert.assertNotNull(child);
Assert.assertTrue(child instanceof AdjacencyTransformer);
AdjacencyTransformer adjacency2 = (AdjacencyTransformer) child;
Assert.assertEquals(adjacency.getAction(), adjacency2.getAction());
Assert.assertEquals(adjacency.getEdgesAre(), adjacency2.getEdgesAre());
Assert.assertEquals(adjacency.getFilterTarget(), adjacency2.getFilterTarget());
Assert.assertEquals(adjacency.getOutput(), adjacency2.getOutput());
CompositeFilter<?, ?> composite = adjacency2.getCompositeFilter();
Assert.assertEquals(1, composite.getLength());
Filter filter = composite.get(0);
Assert.assertTrue(filter instanceof ColumnFilter);
ColumnFilter columnFilter2 = (ColumnFilter) filter;
Assert.assertEquals(columnFilter.getColumnName(), columnFilter2.getColumnName());
Assert.assertEquals(columnFilter.getPredicate(), columnFilter2.getPredicate());
Assert.assertEquals(columnFilter.getCriterion(), columnFilter2.getCriterion());
}
use of org.cytoscape.io.internal.read.transformer.CyTransformerReaderImpl in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
StreamUtilImpl streamUtil = new StreamUtilImpl(serviceRegistrar);
BasicCyFileFilter expressionFilter = new BasicCyFileFilter(new String[] { "pvals" }, new String[] { "text/plain" }, "Cytoscape Expression Matrix", DataCategory.TABLE, streamUtil);
// Always register CYS filters from higher to lower version!
BasicCyFileFilter cys3Filter = new SessionFileFilter(new String[] { "cys" }, new String[] { "application/zip" }, "Cytoscape 3 Session", DataCategory.SESSION, "3.0.0", streamUtil);
BasicCyFileFilter cys2Filter = new SessionFileFilter(new String[] { "cys" }, new String[] { "application/zip" }, "Cytoscape 2 Session", DataCategory.SESSION, "2.0.0", streamUtil);
BasicCyFileFilter pngFilter = new BasicCyFileFilter(new String[] { "png" }, new String[] { "image/png" }, "PNG", DataCategory.IMAGE, streamUtil);
BasicCyFileFilter jpegFilter = new BasicCyFileFilter(new String[] { "jpg", "jpeg" }, new String[] { "image/jpeg" }, "JPEG", DataCategory.IMAGE, streamUtil);
BasicCyFileFilter pdfFilter = new BasicCyFileFilter(new String[] { "pdf" }, new String[] { "image/pdf" }, "PDF", DataCategory.IMAGE, streamUtil);
BasicCyFileFilter psFilter = new BasicCyFileFilter(new String[] { "ps" }, new String[] { "image/ps" }, "PostScript", DataCategory.IMAGE, streamUtil);
BasicCyFileFilter svgFilter = new BasicCyFileFilter(new String[] { "svg" }, new String[] { "image/svg" }, "SVG", DataCategory.IMAGE, streamUtil);
BasicCyFileFilter attrsFilter = new BasicCyFileFilter(new String[] { "attrs" }, new String[] { "text/plain" }, "Text", DataCategory.TABLE, streamUtil);
BasicCyFileFilter sifFilter = new BasicCyFileFilter(new String[] { "sif" }, new String[] { "text/sif" }, "SIF", DataCategory.NETWORK, streamUtil);
BasicCyFileFilter nnfFilter = new BasicCyFileFilter(new String[] { "nnf" }, new String[] { "text/nnf" }, "NNF", DataCategory.NETWORK, streamUtil);
BasicCyFileFilter csvFilter = new BasicCyFileFilter(new String[] { "csv" }, new String[] { "text/plain" }, "CSV", DataCategory.TABLE, streamUtil);
BasicCyFileFilter sessionTableFilter = new BasicCyFileFilter(new String[] { "cytable" }, new String[] { "text/plain" }, "Session Table", DataCategory.TABLE, streamUtil);
GenericXGMMLFileFilter xgmmlFilter = new GenericXGMMLFileFilter(new String[] { "xgmml", "xml" }, new String[] { "text/xgmml", "text/xgmml+xml" }, "XGMML", DataCategory.NETWORK, streamUtil);
SessionXGMMLFileFilter sessXgmmlFileFilter = new SessionXGMMLFileFilter(new String[] { "xgmml" }, new String[] { "text/xgmml", "text/xgmml+xml" }, "Cy3 Session XGMML", DataCategory.NETWORK, streamUtil);
SessionXGMMLNetworkFileFilter sessXgmmlNetFileFilter = new SessionXGMMLNetworkFileFilter(new String[] { "xgmml" }, new String[] { "text/xgmml", "text/xgmml+xml" }, "CYS Network XGMML", DataCategory.NETWORK, streamUtil);
SessionXGMMLNetworkViewFileFilter sessXgmmlViewFileFilter = new SessionXGMMLNetworkViewFileFilter(new String[] { "xgmml" }, new String[] { "text/xgmml", "text/xgmml+xml" }, "CYS View XGMML", DataCategory.NETWORK, streamUtil);
GMLFileFilter gmlFilter = new GMLFileFilter(new String[] { "gml" }, new String[] { "text/gml" }, "GML", DataCategory.NETWORK, streamUtil);
CysessionFileFilter cysessionFilter = new CysessionFileFilter(new String[] { "xml" }, new String[] {}, "Cysession XML", DataCategory.PROPERTIES, streamUtil);
BookmarkFileFilter bookmarksFilter = new BookmarkFileFilter(new String[] { "xml" }, new String[] {}, "Bookmark XML", DataCategory.PROPERTIES, streamUtil);
PropertiesFileFilter propertiesFilter = new PropertiesFileFilter(new String[] { "props", "properties" }, new String[] {}, "Java Properties", DataCategory.PROPERTIES, streamUtil);
VizmapXMLFileFilter vizmapXMLFilter = new VizmapXMLFileFilter(new String[] { "xml" }, new String[] {}, "Style XML", DataCategory.VIZMAP, streamUtil);
VizmapPropertiesFileFilter vizmapPropertiesFilter = new VizmapPropertiesFileFilter(new String[] { "props", "properties" }, new String[] {}, "Vizmap Java Properties", DataCategory.VIZMAP, streamUtil);
CyNetworkReaderManagerImpl networkReaderManager = new CyNetworkReaderManagerImpl(streamUtil);
CyTableReaderManagerImpl tableReaderManager = new CyTableReaderManagerImpl(streamUtil);
CySessionReaderManagerImpl sessionReaderManager = new CySessionReaderManagerImpl(streamUtil);
VizmapReaderManagerImpl vizmapReaderManager = new VizmapReaderManagerImpl(streamUtil);
CyPropertyReaderManagerImpl propertyReaderManager = new CyPropertyReaderManagerImpl(streamUtil);
PresentationWriterManagerImpl viewWriterManager = new PresentationWriterManagerImpl();
CyNetworkViewWriterManagerImpl networkViewWriterManager = new CyNetworkViewWriterManagerImpl();
SessionWriterManagerImpl sessionWriterManager = new SessionWriterManagerImpl();
PropertyWriterManagerImpl propertyWriterManager = new PropertyWriterManagerImpl();
CyTableWriterManagerImpl tableWriterManager = new CyTableWriterManagerImpl();
VizmapWriterManagerImpl vizmapWriterManager = new VizmapWriterManagerImpl();
CalculatorConverterFactory calculatorConverterFactory = new CalculatorConverterFactory();
ExpressionReaderFactory expressionReaderFactory = new ExpressionReaderFactory(expressionFilter, serviceRegistrar);
CyAttributesReaderFactory attrsDataReaderFactory = new CyAttributesReaderFactory(attrsFilter, serviceRegistrar);
SIFNetworkReaderFactory sifNetworkViewReaderFactory = new SIFNetworkReaderFactory(sifFilter, serviceRegistrar);
NNFNetworkReaderFactory nnfNetworkViewReaderFactory = new NNFNetworkReaderFactory(nnfFilter, serviceRegistrar);
UnrecognizedVisualPropertyManager unrecognizedVisualPropertyManager = new UnrecognizedVisualPropertyManager(serviceRegistrar);
GMLNetworkReaderFactory gmlNetworkViewReaderFactory = new GMLNetworkReaderFactory(gmlFilter, unrecognizedVisualPropertyManager, serviceRegistrar);
ReadCache readCache = new ReadCache(serviceRegistrar);
GroupUtil groupUtil = new GroupUtil(serviceRegistrar);
SUIDUpdater suidUpdater = new SUIDUpdater();
ReadDataManager readDataManager = new ReadDataManager(readCache, suidUpdater, groupUtil, serviceRegistrar);
HandlerFactory handlerFactory = new HandlerFactory(readDataManager);
XGMMLParser xgmmlParser = new XGMMLParser(handlerFactory, readDataManager);
GenericXGMMLReaderFactory xgmmlReaderFactory = new GenericXGMMLReaderFactory(xgmmlFilter, readDataManager, xgmmlParser, unrecognizedVisualPropertyManager, serviceRegistrar);
SessionXGMMLNetworkReaderFactory sessXgmmlNetReaderFactory = new SessionXGMMLNetworkReaderFactory(sessXgmmlNetFileFilter, readDataManager, xgmmlParser, unrecognizedVisualPropertyManager, serviceRegistrar);
SessionXGMMLNetworkViewReaderFactory sessXgmmlViewReaderFactory = new SessionXGMMLNetworkViewReaderFactory(sessXgmmlViewFileFilter, readDataManager, xgmmlParser, unrecognizedVisualPropertyManager, serviceRegistrar);
CSVCyReaderFactory sessionTableReaderFactory = new CSVCyReaderFactory(sessionTableFilter, true, true, serviceRegistrar);
Cy3SessionReaderFactoryImpl cy3SessionReaderFactory = new Cy3SessionReaderFactoryImpl(cys3Filter, readCache, groupUtil, suidUpdater, networkReaderManager, propertyReaderManager, vizmapReaderManager, sessionTableReaderFactory, serviceRegistrar);
Cy2SessionReaderFactoryImpl cy2SessionReaderFactory = new Cy2SessionReaderFactoryImpl(cys2Filter, readCache, groupUtil, networkReaderManager, propertyReaderManager, vizmapReaderManager, serviceRegistrar);
CysessionReaderFactory cysessionReaderFactory = new CysessionReaderFactory(cysessionFilter);
BookmarkReaderFactory bookmarkReaderFactory = new BookmarkReaderFactory(bookmarksFilter);
PropertiesReaderFactory propertiesReaderFactory = new PropertiesReaderFactory(propertiesFilter);
VisualStyleSerializer visualStyleSerializer = new VisualStyleSerializer(calculatorConverterFactory, serviceRegistrar);
VizmapXMLReaderFactory vizmapXMLReaderFactory = new VizmapXMLReaderFactory(vizmapXMLFilter, visualStyleSerializer);
VizmapPropertiesReaderFactory vizmapPropertiesReaderFactory = new VizmapPropertiesReaderFactory(vizmapPropertiesFilter, visualStyleSerializer);
BitmapWriterFactory pngWriterFactory = new BitmapWriterFactory(pngFilter);
BitmapWriterFactory jpegWriterFactory = new BitmapWriterFactory(jpegFilter);
PDFWriterFactory pdfWriterFactory = new PDFWriterFactory(pdfFilter);
PSWriterFactory psWriterFactory = new PSWriterFactory(psFilter);
SVGWriterFactory svgWriterFactory = new SVGWriterFactory(svgFilter);
SifNetworkWriterFactory sifNetworkViewWriterFactory = new SifNetworkWriterFactory(sifFilter);
NnfNetworkWriterFactory nnfNetworkViewWriterFactory = new NnfNetworkWriterFactory(nnfFilter, serviceRegistrar);
GenericXGMMLWriterFactory xgmmlWriterFactory = new GenericXGMMLWriterFactory(xgmmlFilter, unrecognizedVisualPropertyManager, groupUtil, serviceRegistrar);
SessionXGMMLWriterFactory sessionXgmmlWriterFactory = new SessionXGMMLWriterFactory(sessXgmmlFileFilter, unrecognizedVisualPropertyManager, serviceRegistrar);
CysessionWriterFactoryImpl cysessionWriterFactory = new CysessionWriterFactoryImpl(cysessionFilter);
BookmarksWriterFactoryImpl bookmarksWriterFactory = new BookmarksWriterFactoryImpl(bookmarksFilter);
PropertiesWriterFactoryImpl propertiesWriterFactory = new PropertiesWriterFactoryImpl(propertiesFilter);
CSVTableWriterFactory csvTableWriterFactory = new CSVTableWriterFactory(csvFilter, false, false, true);
CSVTableWriterFactory sessionTableWriterFactory = new CSVTableWriterFactory(sessionTableFilter, true, true, false);
VizmapWriterFactoryImpl vizmapWriterFactory = new VizmapWriterFactoryImpl(vizmapXMLFilter, visualStyleSerializer);
SessionWriterFactoryImpl sessionWriterFactory = new SessionWriterFactoryImpl(cys3Filter, bookmarksFilter, propertiesFilter, sessionTableFilter, vizmapXMLFilter, sessionXgmmlWriterFactory, propertyWriterManager, tableWriterManager, vizmapWriterManager, groupUtil, serviceRegistrar);
RecentlyOpenedTrackerImpl recentlyOpenedTracker = new RecentlyOpenedTrackerImpl(serviceRegistrar);
CyTransformerReaderImpl transformerReader = new CyTransformerReaderImpl();
CyTransformerWriterImpl transformerWriter = new CyTransformerWriterImpl();
registerService(bc, transformerReader, CyTransformerReader.class);
registerService(bc, transformerWriter, CyTransformerWriter.class);
registerServiceListener(bc, transformerReader::registerTransformerManager, transformerReader::unregisterTransformerManager, TransformerManager.class);
registerService(bc, networkReaderManager, CyNetworkReaderManager.class);
registerService(bc, tableReaderManager, CyTableReaderManager.class);
registerService(bc, vizmapReaderManager, VizmapReaderManager.class);
registerService(bc, viewWriterManager, PresentationWriterManager.class);
registerService(bc, sessionReaderManager, CySessionReaderManager.class);
registerService(bc, propertyReaderManager, CyPropertyReaderManager.class);
registerService(bc, networkViewWriterManager, CyNetworkViewWriterManager.class);
registerService(bc, sessionWriterManager, CySessionWriterManager.class);
registerService(bc, propertyWriterManager, CyPropertyWriterManager.class);
registerService(bc, tableWriterManager, CyTableWriterManager.class);
registerService(bc, vizmapWriterManager, VizmapWriterManager.class);
registerService(bc, sifNetworkViewReaderFactory, InputStreamTaskFactory.class);
registerService(bc, nnfNetworkViewReaderFactory, InputStreamTaskFactory.class);
registerService(bc, xgmmlReaderFactory, InputStreamTaskFactory.class);
registerService(bc, sessXgmmlNetReaderFactory, InputStreamTaskFactory.class);
registerService(bc, sessXgmmlViewReaderFactory, InputStreamTaskFactory.class);
registerService(bc, attrsDataReaderFactory, InputStreamTaskFactory.class);
registerService(bc, gmlNetworkViewReaderFactory, InputStreamTaskFactory.class);
registerService(bc, cy3SessionReaderFactory, InputStreamTaskFactory.class);
registerService(bc, cy2SessionReaderFactory, InputStreamTaskFactory.class);
registerService(bc, cysessionReaderFactory, InputStreamTaskFactory.class);
registerService(bc, bookmarkReaderFactory, InputStreamTaskFactory.class);
registerService(bc, propertiesReaderFactory, InputStreamTaskFactory.class);
registerService(bc, vizmapPropertiesReaderFactory, InputStreamTaskFactory.class);
registerService(bc, vizmapXMLReaderFactory, InputStreamTaskFactory.class);
registerService(bc, sessionTableReaderFactory, InputStreamTaskFactory.class);
registerService(bc, expressionReaderFactory, InputStreamTaskFactory.class);
registerService(bc, streamUtil, StreamUtil.class);
registerService(bc, unrecognizedVisualPropertyManager, NetworkViewAboutToBeDestroyedListener.class);
registerService(bc, recentlyOpenedTracker, RecentlyOpenedTracker.class);
registerServiceListener(bc, networkReaderManager::addInputStreamTaskFactory, networkReaderManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, tableReaderManager::addInputStreamTaskFactory, tableReaderManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, sessionReaderManager::addInputStreamTaskFactory, sessionReaderManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, propertyReaderManager::addInputStreamTaskFactory, propertyReaderManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, vizmapReaderManager::addInputStreamTaskFactory, vizmapReaderManager::removeInputStreamTaskFactory, InputStreamTaskFactory.class);
registerServiceListener(bc, viewWriterManager::addCyWriterFactory, viewWriterManager::removeCyWriterFactory, PresentationWriterFactory.class);
registerServiceListener(bc, networkViewWriterManager::addCyWriterFactory, networkViewWriterManager::removeCyWriterFactory, CyNetworkViewWriterFactory.class);
registerServiceListener(bc, sessionWriterManager::addCyWriterFactory, sessionWriterManager::removeCyWriterFactory, CySessionWriterFactory.class);
registerServiceListener(bc, propertyWriterManager::addCyWriterFactory, propertyWriterManager::removeCyWriterFactory, CyPropertyWriterFactory.class);
registerServiceListener(bc, tableWriterManager::addCyWriterFactory, tableWriterManager::removeCyWriterFactory, CyTableWriterFactory.class);
registerServiceListener(bc, vizmapWriterManager::addCyWriterFactory, vizmapWriterManager::removeCyWriterFactory, VizmapWriterFactory.class);
registerAllServices(bc, pngWriterFactory);
registerAllServices(bc, jpegWriterFactory);
registerAllServices(bc, pdfWriterFactory);
registerAllServices(bc, psWriterFactory);
registerAllServices(bc, svgWriterFactory);
registerAllServices(bc, sifNetworkViewWriterFactory);
registerAllServices(bc, nnfNetworkViewWriterFactory);
registerAllServices(bc, xgmmlWriterFactory);
registerAllServices(bc, cysessionWriterFactory);
registerAllServices(bc, bookmarksWriterFactory);
registerAllServices(bc, propertiesWriterFactory);
registerAllServices(bc, csvTableWriterFactory);
registerAllServices(bc, sessionTableWriterFactory);
registerAllServices(bc, vizmapWriterFactory);
registerAllServices(bc, sessionWriterFactory);
}
use of org.cytoscape.io.internal.read.transformer.CyTransformerReaderImpl in project cytoscape-impl by cytoscape.
the class FilterIOTest method testLoadOldTopologyFilter.
/**
* The topology filter was made a composite filter in 3.3. Older versions of cytoscape
* will export a topology filter without the "transformers" field that is part of
* composite filters. The filter json parser was enhanced to support this.
*/
@SuppressWarnings("rawtypes")
@Test
public void testLoadOldTopologyFilter() throws IOException {
TransformerManagerImpl transformerManager = new TransformerManagerImpl();
Map<String, String> properties = Collections.emptyMap();
transformerManager.registerFilterFactory(new CompositeFilterFactory<CyNetwork, CyIdentifiable>(CyNetwork.class, CyIdentifiable.class), properties);
transformerManager.registerFilterFactory(new TopologyFilterFactory(), properties);
transformerManager.registerFilterFactory(new ColumnFilterFactory(), properties);
String path = "./src/test/resources/testData/filter/topology-filter-3.2.json";
byte[] encoded = Files.readAllBytes(Paths.get(path));
// String contents = new String(encoded);
// System.out.println(contents);
CyTransformerReaderImpl reader = new CyTransformerReaderImpl();
reader.registerTransformerManager(transformerManager, null);
ByteArrayInputStream inputStream = new ByteArrayInputStream(encoded);
NamedTransformer<?, ?>[] transformers = reader.read(inputStream);
Assert.assertNotNull(transformers);
Assert.assertEquals(1, transformers.length);
NamedTransformer<?, ?> namedTransformer = transformers[0];
Assert.assertNotNull(namedTransformer);
Assert.assertEquals("Default filter", namedTransformer.getName());
List children = namedTransformer.getTransformers();
Assert.assertEquals(1, children.size());
Transformer child = (Transformer) children.get(0);
Assert.assertNotNull(child);
Assert.assertTrue(child instanceof CompositeFilter);
CompositeFilter composite = (CompositeFilter) child;
Assert.assertEquals(2, composite.getLength());
Assert.assertTrue(composite.get(0) instanceof TopologyFilter);
Assert.assertTrue(composite.get(1) instanceof ColumnFilter);
TopologyFilter topology = (TopologyFilter) composite.get(0);
Assert.assertEquals(0, topology.getLength());
Assert.assertEquals(Integer.valueOf(4), topology.getDistance());
Assert.assertEquals(Integer.valueOf(5), topology.getThreshold());
ColumnFilter column = (ColumnFilter) composite.get(1);
Assert.assertEquals("name", column.getColumnName());
}
Aggregations