@Test public void testPublishDecodeFailure(@Mocked LogFileParser mockLogFileParser) throws Exception { new Expectations() { { LogFileParser.factory(anyString); result = mockLogFileParser; mockLogFileParser.parseFile((BufferedInputStream) any, anyString); result = ParserStatus.ERROR; } }; List<OdeData> dataList = testLogFileToAsn1CodecPublisher.publish(new BufferedInputStream(new ByteArrayInputStream(new byte[0])), "fileName", ImporterFileType.LEAR_LOG_FILE); assertTrue(dataList.isEmpty()); }
public List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType) throws LogFileToAsn1CodecPublisherException { XmlUtils xmlUtils = new XmlUtils(); ParserStatus status; List<OdeData> dataList = new ArrayList<>(); if (fileType == ImporterFileType.LEAR_LOG_FILE) { fileParser = LogFileParser.factory(fileName); do { try { status = fileParser.parseFile(bis, fileName); if (status == ParserStatus.COMPLETE) { addDataToList(dataList); } else if (status == ParserStatus.EOF) { publishList(xmlUtils, dataList); } else if (status == ParserStatus.INIT) { logger.error("Failed to parse the header bytes."); } else { logger.error("Failed to decode ASN.1 data"); } } catch (Exception e) { throw new LogFileToAsn1CodecPublisherException("Error parsing or publishing data.", e); } } while (status == ParserStatus.COMPLETE); } return dataList; }
LogFileToAsn1CodecPublisher implements Asn1CodecPublisher { public List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType) throws LogFileToAsn1CodecPublisherException { XmlUtils xmlUtils = new XmlUtils(); ParserStatus status; List<OdeData> dataList = new ArrayList<>(); if (fileType == ImporterFileType.LEAR_LOG_FILE) { fileParser = LogFileParser.factory(fileName); do { try { status = fileParser.parseFile(bis, fileName); if (status == ParserStatus.COMPLETE) { addDataToList(dataList); } else if (status == ParserStatus.EOF) { publishList(xmlUtils, dataList); } else if (status == ParserStatus.INIT) { logger.error("Failed to parse the header bytes."); } else { logger.error("Failed to decode ASN.1 data"); } } catch (Exception e) { throw new LogFileToAsn1CodecPublisherException("Error parsing or publishing data.", e); } } while (status == ParserStatus.COMPLETE); } return dataList; } }
LogFileToAsn1CodecPublisher implements Asn1CodecPublisher { public List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType) throws LogFileToAsn1CodecPublisherException { XmlUtils xmlUtils = new XmlUtils(); ParserStatus status; List<OdeData> dataList = new ArrayList<>(); if (fileType == ImporterFileType.LEAR_LOG_FILE) { fileParser = LogFileParser.factory(fileName); do { try { status = fileParser.parseFile(bis, fileName); if (status == ParserStatus.COMPLETE) { addDataToList(dataList); } else if (status == ParserStatus.EOF) { publishList(xmlUtils, dataList); } else if (status == ParserStatus.INIT) { logger.error("Failed to parse the header bytes."); } else { logger.error("Failed to decode ASN.1 data"); } } catch (Exception e) { throw new LogFileToAsn1CodecPublisherException("Error parsing or publishing data.", e); } } while (status == ParserStatus.COMPLETE); } return dataList; } LogFileToAsn1CodecPublisher(StringPublisher dataPub); }
LogFileToAsn1CodecPublisher implements Asn1CodecPublisher { public List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType) throws LogFileToAsn1CodecPublisherException { XmlUtils xmlUtils = new XmlUtils(); ParserStatus status; List<OdeData> dataList = new ArrayList<>(); if (fileType == ImporterFileType.LEAR_LOG_FILE) { fileParser = LogFileParser.factory(fileName); do { try { status = fileParser.parseFile(bis, fileName); if (status == ParserStatus.COMPLETE) { addDataToList(dataList); } else if (status == ParserStatus.EOF) { publishList(xmlUtils, dataList); } else if (status == ParserStatus.INIT) { logger.error("Failed to parse the header bytes."); } else { logger.error("Failed to decode ASN.1 data"); } } catch (Exception e) { throw new LogFileToAsn1CodecPublisherException("Error parsing or publishing data.", e); } } while (status == ParserStatus.COMPLETE); } return dataList; } LogFileToAsn1CodecPublisher(StringPublisher dataPub); List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType); boolean isDriverAlertRecord(); boolean isBsmRecord(); }
LogFileToAsn1CodecPublisher implements Asn1CodecPublisher { public List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType) throws LogFileToAsn1CodecPublisherException { XmlUtils xmlUtils = new XmlUtils(); ParserStatus status; List<OdeData> dataList = new ArrayList<>(); if (fileType == ImporterFileType.LEAR_LOG_FILE) { fileParser = LogFileParser.factory(fileName); do { try { status = fileParser.parseFile(bis, fileName); if (status == ParserStatus.COMPLETE) { addDataToList(dataList); } else if (status == ParserStatus.EOF) { publishList(xmlUtils, dataList); } else if (status == ParserStatus.INIT) { logger.error("Failed to parse the header bytes."); } else { logger.error("Failed to decode ASN.1 data"); } } catch (Exception e) { throw new LogFileToAsn1CodecPublisherException("Error parsing or publishing data.", e); } } while (status == ParserStatus.COMPLETE); } return dataList; } LogFileToAsn1CodecPublisher(StringPublisher dataPub); List<OdeData> publish(BufferedInputStream bis, String fileName, ImporterFileType fileType); boolean isDriverAlertRecord(); boolean isBsmRecord();  }