### Question:
EntityFactory { public Entity getEntity(DrawEntityCommand command) { if (command instanceof DrawLineCommand) { DrawLineCommand cmd = (DrawLineCommand) command; return new Line(cmd.getX1(), cmd.getY1(), cmd.getX2(), cmd.getY2()); } else if (command instanceof DrawRectangleCommand) { DrawRectangleCommand cmd = (DrawRectangleCommand) command; return new Rectangle(cmd.getX1(), cmd.getY1(), cmd.getX2(), cmd.getY2()); } else if (command instanceof BucketFillCommand) { BucketFillCommand cmd = (BucketFillCommand) command; return new BucketFill(cmd.getX(), cmd.getY(), cmd.getCharacter()); } return null; }  Entity getEntity(DrawEntityCommand command);  }### Answer:
@Test public void getEntity_DrawLineCommand() throws Exception { DrawLineCommand drawLineCommand = new DrawLineCommand( "1", "2", "1", "4"); assertEquals(entityFactory.getEntity(drawLineCommand), new Line(1, 2, 1, 4)); }
@Test public void getEntity_DrawRectangleCommand() throws Exception { DrawRectangleCommand drawLineCommand = new DrawRectangleCommand( "1", "2", "3", "4"); assertEquals(entityFactory.getEntity(drawLineCommand), new Rectangle(1, 2, 3, 4)); }
@Test public void getEntity_BucketFillCommand() throws Exception { BucketFillCommand drawLineCommand = new BucketFillCommand( "2", "3", "o"); assertEquals(entityFactory.getEntity(drawLineCommand), new BucketFill(2, 3, 'o')); }
@Test public void getEntity_null() throws Exception { assertEquals(entityFactory.getEntity(null), null); }