/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. */
  16. package com.google.appengine.datanucleus.query;
  17. import com.google.apphosting.api.ApiProxy;
  18. import org.easymock.EasyMock;
  19. import org.easymock.IArgumentMatcher;
  20. /**
  21. * EasyMock matcher for ApiConfig. Delete this once ApiConfig implements
  22. * equals().
  23. *
  24. * @author Max Ross <max.ross@gmail.com>
  25. */
  26. final class ApiConfigMatcher implements IArgumentMatcher {
  27. private final ApiProxy.ApiConfig expectedApiConfig;
  28. ApiConfigMatcher(ApiProxy.ApiConfig expectedApiConfig) {
  29. this.expectedApiConfig = expectedApiConfig;
  30. }
  31. public boolean matches(Object argument) {
  32. ApiProxy.ApiConfig actualApiConfig = (ApiProxy.ApiConfig) argument;
  33. if (expectedApiConfig.getDeadlineInSeconds() == null) {
  34. return actualApiConfig.getDeadlineInSeconds() == null;
  35. }
  36. return expectedApiConfig.getDeadlineInSeconds().equals(actualApiConfig.getDeadlineInSeconds());
  37. }
  38. public void appendTo(StringBuffer buffer) {
  39. buffer.append("ApiConfig Matcher: " + expectedApiConfig.getDeadlineInSeconds());
  40. }
  41. public static ApiProxy.ApiConfig eqApiConfig(ApiProxy.ApiConfig apiConfig) {
  42. EasyMock.reportMatcher(new ApiConfigMatcher(apiConfig));
  43. return null;
  44. }
  45. }