BrowserPage implements Serializable { public final boolean contains(final AbstractHtml tag) throws NullValueException, NotRenderedException { if (tag == null) { throw new NullValueException( "tag object in browserPage.contains(AbstractHtml tag) method cannot be null"); } if (tagByWffId == null) { throw new NotRenderedException( "Could not check its existance. Make sure that you have called browserPage#toHtmlString method atleast once in the life time."); } final DataWffId dataWffId = tag.getDataWffId(); if (dataWffId == null) { return false; } return tag.equals(tagByWffId.get(dataWffId.getValue())); }  abstract String webSocketUrl(); final void setWebSocketPushListener(
            final WebSocketPushListener wsListener); final void addWebSocketPushListener(final String sessionId,
            final WebSocketPushListener wsListener); final void removeWebSocketPushListener(final String sessionId); final WebSocketPushListener getWsListener(); @Deprecated final void websocketMessaged(final byte[] message); final void webSocketMessaged(final byte[] message); abstract AbstractHtml render(); String toHtmlString(); String toHtmlString(final boolean rebuild); String toHtmlString(final String charset); String toHtmlString(final boolean rebuild, final String charset); int toOutputStream(final OutputStream os); int toOutputStream(final OutputStream os, final boolean rebuild); int toOutputStream(final OutputStream os, final boolean rebuild,
            final boolean flushOnWrite); int toOutputStream(final OutputStream os, final String charset); int toOutputStream(final OutputStream os, final Charset charset,
            final boolean flushOnWrite); int toOutputStream(final OutputStream os, final boolean rebuild,
            final String charset); int toOutputStream(final OutputStream os, final boolean rebuild,
            final Charset charset, final boolean flushOnWrite); final String getInstanceId(); final boolean isPushQueueEnabled(); final void setPushQueueEnabled(final boolean enabledPushQueue); final void addServerMethod(final String methodName,
            final ServerAsyncMethod serverAsyncMethod); final void addServerMethod(final String methodName,
            final ServerAsyncMethod serverAsyncMethod,
            final Object serverSideData); final void removeServerMethod(final String methodName); final void performBrowserPageAction(
            final ByteBuffer actionByteBuffer); final boolean isPushQueueOnNewWebSocketListener(); final void setPushQueueOnNewWebSocketListener(
            final boolean pushQueueOnNewWebSocketListener); final boolean isHoldPush(); final void holdPush(); final void unholdPush(); final int getPushQueueSize(); final void removeFromContext(final boolean enable, final On... ons); final boolean contains(final AbstractHtml tag); final int getWebSocketHeartbeatInterval(); static final void setWebSocketDefultHeartbeatInterval(
            final int milliseconds); static final int getWebSocketDefultHeartbeatInterval(); static final void setWebSocketDefultReconnectInterval(
            final int milliseconds); static final int getWebSocketDefultReconnectInterval(); final int getWebSocketReconnectInterval(); final TagRepository getTagRepository(); final String getWffScriptSHA256InBase64(); final String getWffScriptSHA384InBase64(); final String getWffScriptSHA512InBase64(); @Deprecated final PayloadProcessor getPayloadProcessor(); @Deprecated final void removePayloadProcessor(); final PayloadProcessor newPayloadProcessor(); static final String WFF_INSTANCE_ID; }
@Test public void testContains() { final Div div = new Div(null); final Div div2 = new Div(null); BrowserPage browserPage = new BrowserPage() { @Override public String webSocketUrl() { return "wss: } @Override public AbstractHtml render() { Html html = new Html(null) { { new Head(this); new Body(this).appendChild(div); } }; html.setPrependDocType(true); return html; } }; @SuppressWarnings("unused") String toHtmlString = browserPage.toHtmlString(); Assert.assertTrue(browserPage.contains(div)); div.appendChild(div2); Assert.assertTrue(browserPage.contains(div2)); }
@Test(expected = NotRenderedException.class) public void testContainsWithNotRenderedException() { final Div div = new Div(null); BrowserPage browserPage = new BrowserPage() { @Override public String webSocketUrl() { return "wss: } @Override public AbstractHtml render() { Html html = new Html(null) { { new Head(this); new Body(this).appendChild(div); } }; html.setPrependDocType(true); return html; } }; Assert.assertFalse(browserPage.contains(div)); }