### Question:
TextComponent implements RenderableEntity { @Override public Dimension render(Graphics2D graphics) { final FontMetrics fontMetrics = graphics.getFontMetrics(); if (COL_TAG_PATTERN.matcher(text).find()) { final String[] parts = COL_TAG_PATTERN_W_LOOKAHEAD.split(text); int x = position.x; for (String textSplitOnCol : parts) { final String textWithoutCol = textWithoutColTags(textSplitOnCol); final String colColor = textSplitOnCol.substring(textSplitOnCol.indexOf("=") + 1, textSplitOnCol.indexOf(">")); graphics.setColor(Color.BLACK); graphics.drawString(textWithoutCol, x + 1, position.y + 1); graphics.setColor(Color.decode("#" + colColor)); graphics.drawString(textWithoutCol, x, position.y); x += fontMetrics.stringWidth(textWithoutCol); } } else { graphics.setColor(Color.BLACK); graphics.drawString(text, position.x + 1, position.y + 1); graphics.setColor(color); graphics.drawString(text, position.x, position.y); } return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight()); }  static String textWithoutColTags(String text); @Override Dimension render(Graphics2D graphics);  }### Answer:
@Test public void testRender() { TextComponent textComponent = new TextComponent(); textComponent.setText("test"); textComponent.setColor(Color.RED); textComponent.render(graphics); verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); verify(graphics, atLeastOnce()).setColor(Color.RED); }
@Test public void testRender2() { TextComponent textComponent = new TextComponent(); textComponent.setText("<col=0000ff>test"); textComponent.render(graphics); verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt()); verify(graphics, atLeastOnce()).setColor(Color.BLUE); }
@Test public void testRender3() { TextComponent textComponent = new TextComponent(); textComponent.setText("<col=0000ff>test<col=00ff00> test"); textComponent.render(graphics); verify(graphics, atLeastOnce()).drawString(eq("test"), anyInt(), anyInt()); verify(graphics, atLeastOnce()).drawString(eq(" test"), anyInt(), anyInt()); verify(graphics, atLeastOnce()).setColor(Color.BLUE); verify(graphics, atLeastOnce()).setColor(Color.GREEN); }