### Question:
ResourceAttributeHandler extends TextAttributeHandler { @Override public void startAttribute(Attributes attributes, String qName) throws SAXException { if (this.isIntoMetadatas()) { this.startMetadata(attributes, qName); } else if (qName.equals("resource")) { this.startResource(attributes, qName); } else if (qName.equals("metadatas")) { this.setIntoMetadatas(true); } else if (qName.equals(IResourceManager.ALT_METADATA_KEY) || qName.equals(IResourceManager.DESCRIPTION_METADATA_KEY) || qName.equals(IResourceManager.LEGEND_METADATA_KEY) || qName.equals(IResourceManager.TITLE_METADATA_KEY)) { this.startResourceMetadata(qName, attributes, qName); } else { super.startAttribute(attributes, qName); } }  @Override Object getAttributeHandlerPrototype(); @Override void startAttribute(Attributes attributes, String qName); @Override void endAttribute(String qName, StringBuffer textBuffer); void setResourceManager(IResourceManager resourceManager);  }### Answer:
@Test public void startAttribute_3() throws Exception { when(attributes.getIndex("lang")).thenReturn(1); when(attributes.getValue(1)).thenReturn("en"); when(attributes.getIndex("id")).thenReturn(2); when(attributes.getValue(2)).thenReturn("id_1"); ImageResource resource = new ImageResource(); when(resourceManager.loadResource("id_1")).thenReturn(resource); handler.startAttribute(attributes, "resource"); Mockito.verify(currentAttr, Mockito.times(1)).setResource(ArgumentMatchers.any(ImageResource.class), ArgumentMatchers.eq("en")); }
@Test public void startAttribute_4() throws Exception { when(attributes.getIndex("lang")).thenReturn(1); when(attributes.getValue(1)).thenReturn(null); when(attributes.getIndex("id")).thenReturn(2); when(attributes.getValue(2)).thenReturn("id_2"); when(resourceManager.loadResource("id_2")).thenReturn(null); handler.startAttribute(attributes, "resource"); Mockito.verify(currentAttr, Mockito.times(0)).setResource(ArgumentMatchers.any(ImageResource.class), ArgumentMatchers.eq("en")); }
@Test(expected = SAXException.class) public void startAttribute_7() throws SAXException { when(attributes.getIndex("lang")).thenReturn(1); when(attributes.getValue(1)).thenReturn(null); handler.startAttribute(attributes, "text"); Assert.fail(); }
@Test public void startAttribute_8() throws SAXException { when(attributes.getIndex("lang")).thenReturn(2); when(attributes.getValue(2)).thenReturn("en"); handler.startAttribute(attributes, "text"); Assert.assertEquals("en", handler.getCurrentLangId()); }