### Question:
DefaultInstructionParser implements InstructionParser { @Override public Instructions parseInstructions(final String content) { if (Strings.isNullOrEmpty(content)) { log.warn("Instructions content was null"); return null; } try { final JAXBContext context = JAXBContext.newInstance(PluginInstructions.class); final Unmarshaller unmarshaller = context.createUnmarshaller(); final Instructions instructions = (Instructions) unmarshaller.unmarshal(new StringReader(content)); final Set<InstructionSet> instructionSets = instructions.getInstructionSets(); for (InstructionSet instructionSet : instructionSets) { final Set<Instruction> myInstr = instructionSet.getInstructions(); for (Instruction instruction : myInstr) { injector.autowireBean(instruction); } } injector.autowireBean(instructions); return instructions; } catch (JAXBException e) { log.error("Error parsing instruction", e); } return null; }  @Override Instructions parseInstructions(final String content);  }### Answer:
@Test public void testParseInstructions() throws Exception { final InputStream resourceAsStream = getClass().getResourceAsStream("/parser_instructions.xml"); final String content = GlobalUtils.readStreamAsText(resourceAsStream); final Instructions myInstructions = instructionParser.parseInstructions(content); final Set<InstructionSet> iset = myInstructions.getInstructionSets(); assertEquals(3, iset.size()); final Iterator<InstructionSet> myIterator = iset.iterator(); final InstructionSet set1 = myIterator.next(); final InstructionSet set2 = myIterator.next(); assertEquals("myGroup", set1.getGroups().iterator().next()); assertEquals(EssentialConst.INSTRUCTION_GROUP_DEFAULT, set2.getGroups().iterator().next()); assertEquals(6, set1.getInstructions().size()); assertEquals(1, set2.getInstructions().size()); assertEquals(8, myInstructions.totalInstructions()); assertEquals(3, myInstructions.totalInstructionSets()); final Instructions value = new PluginInstructions(); final Set<InstructionSet> instructionSets = new HashSet<>(); final PluginInstructionSet instructionSet = new PluginInstructionSet(); addInstructions(instructionSet); instructionSets.add(instructionSet); value.setInstructionSets(instructionSets); final JAXBContext context = JAXBContext.newInstance(PluginInstructions.class); final Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); final StringWriter writer = new StringWriter(); m.marshal(value, writer); final String s = writer.toString(); log.info("s {}", s); final Instructions instructions = instructionParser.parseInstructions(s); assertTrue(instructions != null); final InstructionSet set = instructions.getInstructionSets().iterator().next(); final Set<Instruction> mySet = set.getInstructions(); final Iterator<Instruction> iterator = mySet.iterator(); for (int i = 0; i < mySet.size(); i++) { final Instruction next = iterator.next(); final int isMod3 = i % 3; if (isMod3 == 0) { assertTrue(next.getMessage().equals(String.format("XML%d", i))); } else { assertTrue(next.getMessage().equals(String.format("FILE%d", i))); } } }