MorphlineUtils { public static Pipeline getPipeline(String morphlineFile, String morphlineId) { LOG.debug("Retrieving Pipeline[{}#{}]", morphlineFile, morphlineId); if (null == pipelineCache.get()) { LOG.trace("Initializing ThreadLocal cache"); pipelineCache.set(new HashMap<String, Pipeline>()); return null; } return pipelineCache.get().get(morphlineFile + SEPARATOR + morphlineId); }  static Pipeline getPipeline(String morphlineFile, String morphlineId); static Pipeline setPipeline(String morphlineFile, String morphlineId, Collector collector, boolean isProduction); static List<Record> executePipeline(Pipeline pipeline, Record inputRecord); static List<Record> executePipeline(Pipeline pipeline, Record inputRecord, boolean errorOnEmpty); @SuppressWarnings("serial") static FlatMapFunction<Row, Row> morphlineMapper(final String morphlineFile, final String morphlineId,
                                                          final StructType outputSchema, final boolean errorOnEmpty); static Row convertToRow(StructType schema, Record record);  }
@Ignore @Test public void getPipeline( final @Mocked ThreadLocal<Map<String, MorphlineUtils.Pipeline>> pipelineCache, final @Mocked Map<String, MorphlineUtils.Pipeline> cacheMap, final @Mocked MorphlineUtils.Pipeline returnedPipeline ) throws Exception { new Expectations() {{ pipelineCache.get(); returns(null, cacheMap); times = 2; cacheMap.get("morphlineFile-morphlineId"); result = returnedPipeline; times = 1; }}; assertNull("First invocation is not null", MorphlineUtils.getPipeline("morphlineFile", "morphlineId")); }