PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/com/google/appengine/datanucleus/query/ApiConfigMatcher.java

http://datanucleus-appengine.googlecode.com/
Java | 53 lines | 24 code | 8 blank | 21 comment | 3 complexity | 2dd1f8e11bf7a7a5472013ebb805e43d MD5 | raw file
 1/*
 2 * Copyright (C) 2010 Google Inc
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.google.appengine.datanucleus.query;
17
18import com.google.apphosting.api.ApiProxy;
19
20import org.easymock.EasyMock;
21import org.easymock.IArgumentMatcher;
22
23/**
24 * EasyMock matcher for ApiConfig.  Delete this once ApiConfig implements
25 * equals().
26 *
27 * @author Max Ross <max.ross@gmail.com>
28 */
29final class ApiConfigMatcher implements IArgumentMatcher {
30  private final ApiProxy.ApiConfig expectedApiConfig;
31
32  ApiConfigMatcher(ApiProxy.ApiConfig expectedApiConfig) {
33    this.expectedApiConfig = expectedApiConfig;
34  }
35
36  public boolean matches(Object argument) {
37    ApiProxy.ApiConfig actualApiConfig = (ApiProxy.ApiConfig) argument;
38    if (expectedApiConfig.getDeadlineInSeconds() == null) {
39      return actualApiConfig.getDeadlineInSeconds() == null;
40    }
41    return expectedApiConfig.getDeadlineInSeconds().equals(actualApiConfig.getDeadlineInSeconds());
42  }
43
44  public void appendTo(StringBuffer buffer) {
45    buffer.append("ApiConfig Matcher: " + expectedApiConfig.getDeadlineInSeconds());
46  }
47
48  public static ApiProxy.ApiConfig eqApiConfig(ApiProxy.ApiConfig apiConfig) {
49    EasyMock.reportMatcher(new ApiConfigMatcher(apiConfig));
50    return null;
51  }
52
53}