ParsingError extends RoboconfError { @Override public boolean equals( Object obj ) { return super.equals( obj ) && Objects.equals( this.line, ((ParsingError) obj).line ) && Objects.equals( this.file, ((ParsingError) obj).file ); } ParsingError( ErrorCode errorCode, File file, int line );  ParsingError( ErrorCode errorCode, File file, int line, ErrorDetails... details ); int getLine(); File getFile(); @Override boolean equals( Object obj ); @Override int hashCode();  }
@Test public void testEquals() { File f = new File( "1" ); ParsingError def1 = new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 1 ); ParsingError def2 = new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 2 ); ParsingError def3 = new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 2, value( "v" )); RoboconfError def4 = new RoboconfError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, value( "v" )); Assert.assertTrue( def1.equals( def1 )); Assert.assertTrue( def1.equals( new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 1 ))); Assert.assertFalse( def1.equals( new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, new File( "2" ), 1 ))); Assert.assertFalse( def1.equals( null )); Assert.assertFalse( def1.equals( new Object())); Assert.assertFalse( def1.equals( def2 )); Assert.assertFalse( def1.equals( def3 )); Assert.assertFalse( def1.equals( def4 )); Assert.assertTrue( def2.equals( def2 )); Assert.assertTrue( def2.equals( new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 2 ))); Assert.assertFalse( def2.equals( def3 )); Assert.assertFalse( def2.equals( def1 )); Assert.assertFalse( def2.equals( def4 )); Assert.assertTrue( def3.equals( def3 )); Assert.assertTrue( def3.equals( new ParsingError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, f, 2, value( "v" )))); Assert.assertFalse( def3.equals( def1 )); Assert.assertFalse( def3.equals( def2 )); Assert.assertFalse( def3.equals( def4 )); Assert.assertTrue( def4.equals( def4 )); Assert.assertTrue( def4.equals( new RoboconfError( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, value( "v" )))); }