### Question:
Triangle { public double area() { double area = -1; double ab = this.a.distanceTo(this.b); double ac = this.a.distanceTo(this.c); double bc = this.b.distanceTo(this.c); double p = this.period(ab, ac, bc); if (this.exist(ab, ac, bc)) { area = Math.sqrt(p * (p - ab) * (p - ac) * (p - bc)); } return area; } Triangle(Point a, Point b, Point c); double period(double ab, double ac, double bc); double area();  }### Answer:
@Test public void whenAreaSetThreePointsThenTreangleArea() { Point a = new Point(0, 0); Point b = new Point(0, 2); Point c = new Point(2, 0); Triangle triangle = new Triangle(a, b, c); double result = triangle.area(); double expected = 2D; assertThat(result, closeTo(expected, 0.1)); }
@Test public void whenExistFalse() { Point a = new Point(0, 0); Point b = new Point(0, 0); Point c = new Point(0, 1); Triangle triangle = new Triangle(a, b, c); double result = triangle.area(); double expected = -1D; assertThat(result, is(expected)); }