@Test public void testParseTapeDriveStatusOpen() throws Exception { String statusOutPut = PropertiesUtils.getResourceAsString("output/tape-drive-status-open.txt"); final TapeDriveStatusParser tapeDriveStatusParser = new TapeDriveStatusParser(); final TapeDriveState tapeDriveState = tapeDriveStatusParser.parse(statusOutPut); Assertions.assertThat(tapeDriveState).isNotNull(); String expected = "result/tape-drive-status-open.json"; JsonNode initialJson = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(expected)); JsonAssert.assertJsonEquals(JsonHandler.toJsonNode(tapeDriveState), initialJson); }
public TapeDriveState parse(String output) { ParametersChecker.checkParameter("All params is required", output); final TapeDriveState tapeDriveState = new TapeDriveState(StatusCode.OK); for (String s : output.split("\n")) { if (s.contains(TAPE_DRIVE)) { tapeDriveState.setDescription(s.trim()); } else if (s.contains(FILE_NUMBER)) { extractFileAndBlockNumberAndPartition(tapeDriveState, s); } else if (s.contains(TAPE_BLOCK_SIZE)) { extractBlockSizeAndDensity(tapeDriveState, s); } else if (s.contains(SOFT_ERROR)) { extractSoftErrorCount(tapeDriveState, s); } else if (s.contains(GENERAL_STATUS)) { extractGeneralStatus(tapeDriveState, s); } else { extractDriveStatus(tapeDriveState, s); } } return tapeDriveState; }
TapeDriveStatusParser { public TapeDriveState parse(String output) { ParametersChecker.checkParameter("All params is required", output); final TapeDriveState tapeDriveState = new TapeDriveState(StatusCode.OK); for (String s : output.split("\n")) { if (s.contains(TAPE_DRIVE)) { tapeDriveState.setDescription(s.trim()); } else if (s.contains(FILE_NUMBER)) { extractFileAndBlockNumberAndPartition(tapeDriveState, s); } else if (s.contains(TAPE_BLOCK_SIZE)) { extractBlockSizeAndDensity(tapeDriveState, s); } else if (s.contains(SOFT_ERROR)) { extractSoftErrorCount(tapeDriveState, s); } else if (s.contains(GENERAL_STATUS)) { extractGeneralStatus(tapeDriveState, s); } else { extractDriveStatus(tapeDriveState, s); } } return tapeDriveState; } }
TapeDriveStatusParser { public TapeDriveState parse(String output) { ParametersChecker.checkParameter("All params is required", output); final TapeDriveState tapeDriveState = new TapeDriveState(StatusCode.OK); for (String s : output.split("\n")) { if (s.contains(TAPE_DRIVE)) { tapeDriveState.setDescription(s.trim()); } else if (s.contains(FILE_NUMBER)) { extractFileAndBlockNumberAndPartition(tapeDriveState, s); } else if (s.contains(TAPE_BLOCK_SIZE)) { extractBlockSizeAndDensity(tapeDriveState, s); } else if (s.contains(SOFT_ERROR)) { extractSoftErrorCount(tapeDriveState, s); } else if (s.contains(GENERAL_STATUS)) { extractGeneralStatus(tapeDriveState, s); } else { extractDriveStatus(tapeDriveState, s); } } return tapeDriveState; }  }
TapeDriveStatusParser { public TapeDriveState parse(String output) { ParametersChecker.checkParameter("All params is required", output); final TapeDriveState tapeDriveState = new TapeDriveState(StatusCode.OK); for (String s : output.split("\n")) { if (s.contains(TAPE_DRIVE)) { tapeDriveState.setDescription(s.trim()); } else if (s.contains(FILE_NUMBER)) { extractFileAndBlockNumberAndPartition(tapeDriveState, s); } else if (s.contains(TAPE_BLOCK_SIZE)) { extractBlockSizeAndDensity(tapeDriveState, s); } else if (s.contains(SOFT_ERROR)) { extractSoftErrorCount(tapeDriveState, s); } else if (s.contains(GENERAL_STATUS)) { extractGeneralStatus(tapeDriveState, s); } else { extractDriveStatus(tapeDriveState, s); } } return tapeDriveState; }  TapeDriveState parse(String output); }
TapeDriveStatusParser { public TapeDriveState parse(String output) { ParametersChecker.checkParameter("All params is required", output); final TapeDriveState tapeDriveState = new TapeDriveState(StatusCode.OK); for (String s : output.split("\n")) { if (s.contains(TAPE_DRIVE)) { tapeDriveState.setDescription(s.trim()); } else if (s.contains(FILE_NUMBER)) { extractFileAndBlockNumberAndPartition(tapeDriveState, s); } else if (s.contains(TAPE_BLOCK_SIZE)) { extractBlockSizeAndDensity(tapeDriveState, s); } else if (s.contains(SOFT_ERROR)) { extractSoftErrorCount(tapeDriveState, s); } else if (s.contains(GENERAL_STATUS)) { extractGeneralStatus(tapeDriveState, s); } else { extractDriveStatus(tapeDriveState, s); } } return tapeDriveState; }  TapeDriveState parse(String output);  }