All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.web.bindery.requestfactory.gwt.client.testing.MockRequestFactoryEditorDriver Maven / Gradle / Ivy

There is a newer version: 2.10.0
Show newest version
/*
 * Copyright 2010 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.web.bindery.requestfactory.gwt.client.testing;

import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.EditorError;
import com.google.gwt.editor.client.EditorVisitor;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver;
import com.google.web.bindery.requestfactory.shared.RequestContext;
import com.google.web.bindery.requestfactory.shared.RequestFactory;

import java.util.Collections;
import java.util.List;

import javax.validation.ConstraintViolation;

/**
 * A no-op implementation of {@link RequestFactoryEditorDriver} that records its
 * inputs.
 * 
 * @param 

the Proxy type being edited * @param the Editor type */ public class MockRequestFactoryEditorDriver> implements RequestFactoryEditorDriver { private static final String[] EMPTY_STRING = new String[0]; private EventBus eventBus; private E editor; private P proxy; private RequestContext saveRequest; private RequestFactory requestFactory; /** * A no-op method. */ public void accept(EditorVisitor visitor) { } /** * Records its arguments. */ public void display(P proxy) { this.proxy = proxy; } /** * Records its arguments. */ public void edit(P proxy, RequestContext saveRequest) { this.proxy = proxy; this.saveRequest = saveRequest; } /** * Returns null or the last value recorded. */ public RequestContext flush() { return saveRequest; } /** * Returns null or the last value recorded. */ public E getEditor() { return editor; } /** * Returns an empty list. */ public List getErrors() { return Collections.emptyList(); } /** * Returns null or the last value recorded. */ public EventBus getEventBus() { return eventBus; } /** * Returns a zero-length array. */ public String[] getPaths() { return EMPTY_STRING; } /** * Returns null or the last value recorded. */ public P getProxy() { return proxy; } /** * Returns null or the last value recorded. */ public RequestFactory getRequestFactory() { return requestFactory; } /** * Returns null or the last value recorded. */ public RequestContext getSaveRequest() { return saveRequest; } /** * Returns false. */ public boolean hasErrors() { return false; } public void initialize(E editor) { initialize(null, editor); } /** * Records its arguments. */ public void initialize(EventBus eventBus, RequestFactory requestFactory, E editor) { this.eventBus = eventBus; this.requestFactory = requestFactory; this.editor = editor; } public void initialize(RequestFactory requestFactory, E editor) { this.initialize(requestFactory.getEventBus(), requestFactory, editor); } /** * Returns {@code false}. */ public boolean isDirty() { return false; } /** * A no-op method that always returns false. */ public boolean setConstraintViolations( Iterable> violations) { return false; } /** * A no-op method that always returns false. */ @SuppressWarnings("deprecation") public boolean setViolations(Iterable errors) { return false; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy