Figure { public static FigureBuilder builder() { return new FigureBuilder(); } Figure(FigureBuilder builder);  Figure(Trace... traces);  Figure(Layout layout, Trace... traces);  Figure(Layout layout, Config config, Trace... traces); @Deprecated  Figure(Layout layout, EventHandler eventHandler, Trace... traces); @Deprecated  Figure(Layout layout, EventHandler[] eventHandlers, Trace... traces); String divString(String divName); Layout getLayout(); void setLayout(Layout layout); Config getConfig(); void setConfig(Config config); EventHandler[] getEventHandlers(); void setEventHandlers(EventHandler... handlers); Trace[] getTraces(); void setTraces(Trace... data); String asJavascript(String divName); Map<String, Object> getContext(); static FigureBuilder builder();  }
@Test void builder() { String title = "A test title"; Layout layout = Layout.builder().title(title).showLegend(true).build(); Trace trace = ScatterTrace.builder(x, y).build(); Figure figure = Figure.builder().layout(layout).addTraces(trace).build(); assertEquals(layout, figure.getLayout()); figure.asJavascript(divName); assertTrue(String.valueOf(figure.getContext().get("figure")).contains(title)); }