### Question:
Geom { public static Optional<Coord> intersection(Line l1, Line l2) { Check.notNull(l1); Check.notNull(l2); final double x1 = l1.getX1(); final double x2 = l1.getX2(); final double y1 = l1.getY1(); final double y2 = l1.getY2(); final double x3 = l2.getX1(); final double x4 = l2.getX2(); final double y3 = l2.getY1(); final double y4 = l2.getY2(); final double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); if (Double.compare(d, 0) == 0) { return Optional.empty(); } final double xi = ((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d; final double yi = ((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d; return Optional.of(new Coord(xi, yi)); } private  Geom(); static Optional<Coord> intersection(Line l1, Line l2); static Localizable createLocalizable(double x, double y); static Area createArea(double x, double y, double width, double height); static boolean same(Localizable a, Localizable b);  }### Answer:
@Test void testNoIntersection() { assertFalse(Geom.intersection(new Line(), new Line()).isPresent()); assertFalse(Geom.intersection(new Line(0.0, 0.0, 2.0, 2.0), new Line(2.0, 2.0, 4.0, 4.0)).isPresent()); assertFalse(Geom.intersection(new Line(1.0, 2.0, 3.0, 4.0), new Line(-1.0, -2.0, -3.0, -4.0)).isPresent()); assertFalse(Geom.intersection(new Line(0.0, 2.0, 4.0, 2.0), new Line(0.0, 1.99, 4.0, 1.99)).isPresent()); assertFalse(Geom.intersection(new Line(0.0, 2.0, 4.0, 2.0), new Line(0.0, 2.01, 4.0, 2.01)).isPresent()); }
@Test void testIntersection() { assertEquals(new Coord(1.0, 2.0), Geom.intersection(new Line(0.0, 2.0, 2.0, 2.0), new Line(1.0, 0.0, 1.0, 4.0)).get()); assertEquals(new Coord(1.0, 2.0), Geom.intersection(new Line(0.0, 4.0, 2.0, 0.0), new Line(0.0, 0.0, 2.0, 4.0)).get()); }
@Test void testIntersectionNullArgument1() { assertThrows(() -> Geom.intersection(null, new Line()).isPresent(), "Unexpected null argument !"); }
@Test void testIntersectionNullArgument2() { assertThrows(() -> Geom.intersection(new Line(), null).isPresent(), "Unexpected null argument !"); }