Java 类org.easymock.LogicalOperator 实例源码

项目:BingAds-Java-SDK    文件:BulkAdGroupNegativeSitesWriteTest.java   
@Test
public void testWriteToStream() throws IOException {
    AdGroupNegativeSites apiAdGroupNegativeSites = new AdGroupNegativeSites();
    apiAdGroupNegativeSites.setAdGroupId(123L);

    ArrayOfstring arrayOfBulkAdGroupNegativeSites = new ArrayOfstring();
    List<String> bulkAdGroupNegativeSites = arrayOfBulkAdGroupNegativeSites.getStrings();
    bulkAdGroupNegativeSites.add("Site 1");
    bulkAdGroupNegativeSites.add("Site 2");
    apiAdGroupNegativeSites.setNegativeSites(arrayOfBulkAdGroupNegativeSites);

    BulkAdGroupNegativeSites adGroupNegativeSites = new BulkAdGroupNegativeSites();
    adGroupNegativeSites.setAdGroupName("Test Ad Group");
    adGroupNegativeSites.setAdGroupNegativeSites(apiAdGroupNegativeSites);

    BulkAdGroupNegativeSitesIdentifier identifier = new BulkAdGroupNegativeSitesIdentifier();
    identifier.setAdGroupId(123L);
    identifier.setStatus(Status.DELETED);

    BulkAdGroupNegativeSite bulkAdGroupNegativeSite1 = new BulkAdGroupNegativeSite();
    bulkAdGroupNegativeSite1.setAdGroupId(123L);
    bulkAdGroupNegativeSite1.setWebsite(apiAdGroupNegativeSites.getNegativeSites().getStrings().get(0));
    BulkAdGroupNegativeSite bulkAdGroupNegativeSite2 = new BulkAdGroupNegativeSite();
    bulkAdGroupNegativeSite2.setAdGroupId(123L);
    bulkAdGroupNegativeSite2.setWebsite(apiAdGroupNegativeSites.getNegativeSites().getStrings().get(1));

    rowWriter.writeObjectRow(and(anyObject(BulkAdGroupNegativeSitesIdentifier.class), cmp(identifier, IDENTIFIER_COMPARATOR, LogicalOperator.EQUAL)), eq(false));
    rowWriter.writeObjectRow(and(anyObject(BulkAdGroupNegativeSite.class), cmp(bulkAdGroupNegativeSite1, BULK_NEGATIVE_SITE_COMPARATOR, LogicalOperator.EQUAL)), eq(false));
    rowWriter.writeObjectRow(and(anyObject(BulkAdGroupNegativeSite.class), cmp(bulkAdGroupNegativeSite2, BULK_NEGATIVE_SITE_COMPARATOR, LogicalOperator.EQUAL)), eq(false));
    replayAll();
    adGroupNegativeSites.writeToStream(rowWriter, false);
}
项目:BingAds-Java-SDK    文件:BulkSiteLinkAdExtensionWriteToStreamTest.java   
@Test
public void test() throws IOException {
    SiteLinksAdExtension apiAdExtension = new SiteLinksAdExtension();
    apiAdExtension.setId(10L);

    ArrayOfSiteLink arrayOfSiteLinks = new ArrayOfSiteLink();
    List<SiteLink> siteLinks = arrayOfSiteLinks.getSiteLinks();
    siteLinks.add(new SiteLink());
    siteLinks.add(new SiteLink());
    apiAdExtension.setSiteLinks(arrayOfSiteLinks);

    BulkSiteLinkAdExtension adExtension = new BulkSiteLinkAdExtension();
    adExtension.setAccountId(123L);
    adExtension.setSiteLinksAdExtension(apiAdExtension);

    SiteLinkAdExtensionIdentifier identifier = new SiteLinkAdExtensionIdentifier();
    identifier.setAccountId(123L);
    identifier.setAdExtensionId(10L);
    identifier.setStatus(AdExtensionStatus.DELETED);
    BulkSiteLink siteLink1 = new BulkSiteLink();
    siteLink1.setAccountId(123L);
    siteLink1.setSiteLink(apiAdExtension.getSiteLinks().getSiteLinks().get(0));
    BulkSiteLink siteLink2 = new BulkSiteLink();
    siteLink2.setAccountId(123L);
    siteLink2.setSiteLink(apiAdExtension.getSiteLinks().getSiteLinks().get(1));

    rowWriter.writeObjectRow(and(anyObject(SiteLinkAdExtensionIdentifier.class), cmp(identifier, IDENTIFIER_COMPARATOR, LogicalOperator.EQUAL)), eq(false));
    rowWriter.writeObjectRow(and(anyObject(BulkSiteLink.class), cmp(siteLink1, BULK_SITE_LINK_COMPARATOR, LogicalOperator.EQUAL)), eq(false));
    rowWriter.writeObjectRow(and(anyObject(BulkSiteLink.class), cmp(siteLink2, BULK_SITE_LINK_COMPARATOR, LogicalOperator.EQUAL)), eq(false));

    replayAll();
    adExtension.writeToStream(rowWriter, false);
}
项目:external-android-mock    文件:AndroidMockTest.java   
public void testCmp() {
  Map<?, ?> mockMap = AndroidMock.createMock(Map.class);
  AndroidMock.expect(
      mockMap.get(AndroidMock.cmp("hi", String.CASE_INSENSITIVE_ORDER, LogicalOperator.EQUAL)))
      .andReturn(null);
  AndroidMock.replay(mockMap);
}
项目:gerrit-rest-java-client    文件:ProjectsRestClientTest.java   
public ProjectsParser setupProjectsParser() throws Exception {
    projectsParser = EasyMock.createMock(ProjectsParser.class);
    EasyMock.expect(projectsParser.generateProjectInput(
            EasyMock.cmp(mockProjectInput,
                    new SameName(),
                    LogicalOperator.EQUAL)))
            .andReturn(mockJsonString)
            .once();
    EasyMock.expect(projectsParser.parseSingleProjectInfo(mockJsonElement))
            .andReturn(mockProjectInfo)
            .once();
    EasyMock.replay(projectsParser);
    return projectsParser;
}
项目:external-android-mock    文件:AndroidMock.java   
/**
 * Expects an argument that will be compared using the provided {@link java.util.Comparator}, the
 * result of which will then be applied to the provided {@link org.easymock.LogicalOperator}
 * (e.g. {@link org.easymock.LogicalOperator#LESS_THAN},
 * {@link org.easymock.LogicalOperator#EQUAL},
 * {@link org.easymock.LogicalOperator#GREATER_OR_EQUAL}).
 * 
 * The following comparison will take place:
 * {@code comparator.compare(actual, expected) operator 0}
 * 
 * E.g.
 * For illustration purposes (using static imports):
 * 
 * {@code
 * expect(mockObject.getString(cmp("hi", CASE_INSENSITIVE_ORDER, LESS_THAN))).andReturn("hello");}
 *
 * {@code
 * AndroidMock.expect(mockObject.getString(AndroidMock.cmp("hi", String.CASE_INSENSITIVE_ORDER,
 *    LogicalOperator.LESS_THAN))).andReturn("hello");}
 * 
 * 
 * The above invocation indicates that the call to {@code mockObject.getString(String)} is
 * expecting any String which is lexically before "hi" (in a case insensitive ordering).
 * 
 * If this method is used for anything other than to set a parameter expectation as part of a
 * mock object's recording phase, then an {@code IllegalStateException} will be thrown.
 * 
 * @param expectedValue the expected value against which the incoming method parameter will be
 * compared.
 * @param comparator {@link java.util.Comparator} used to perform the comparison between the
 * expected value and the incoming parameter to the mocked method.
 * @param operator The comparison operator, usually one of
 * {@link org.easymock.LogicalOperator#LESS_THAN},
 * {@link org.easymock.LogicalOperator#LESS_OR_EQUAL},
 * {@link org.easymock.LogicalOperator#EQUAL}, {@link org.easymock.LogicalOperator#GREATER},
 * {@link org.easymock.LogicalOperator#GREATER_OR_EQUAL} 
 * @return {@code null}. The return value is always ignored.
 */
public static <T> T cmp(T expectedValue, Comparator<? super T> comparator,
    LogicalOperator operator) {
  return EasyMock.cmp(expectedValue, comparator, operator);
}
项目:panifex-platform    文件:TestSupport.java   
/**
 * Expects an argument that will be compared using the provided comparator.
 * The following comparison will take place:
 * <p>
 * <code>comparator.compare(actual, expected) operator 0</code>
 * </p>
 * For details, see the EasyMock documentation.
 *
 * @param <T>
 *            type of the method argument to match
 * @param value
 *            the given value.
 * @param comparator
 *            Comparator used to compare the actual with expected value.
 * @param operator
 *            The comparison operator.
 * @return <code>null</code>
 */
protected final <T> T cmp(final T value, final Comparator<? super T> comparator,
        final LogicalOperator operator) {
    return EasyMock.cmp(value, comparator, operator);
}