Ejemplo n.º 1
0
  @Test
  public void testHandleRequestPartitionClosedSlave() throws Exception {
    final int partition = 1;
    final int opaque = 0;
    final int maxSize = 1024;
    final long offset = 10;

    this.metaConfig.setTopics(Arrays.asList(this.topic));
    this.metaConfig.closePartitions(this.topic, partition, partition);

    final MessageStore store = this.mocksControl.createMock(MessageStore.class);
    EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
    final MessageSet set = this.mocksControl.createMock(MessageSet.class);
    EasyMock.expect(store.slice(offset, maxSize)).andReturn(set);

    final GetCommand request =
        new GetCommand(
            this.topic, this.metaConfig.getSlaveGroup(), partition, offset, maxSize, opaque);
    // this.conn.response(new BooleanCommand(request.getOpaque(),
    // HttpStatus.Forbidden, "partition["
    // + this.metaConfig.getBrokerId() + "-" + request.getPartition() +
    // "] have been closed"));
    set.write(request, this.sessionContext);
    EasyMock.expectLastCall();

    this.mocksControl.replay();

    this.getProcessor.handleRequest(request, this.conn);
    this.mocksControl.verify();
    assertEquals(0, this.statsManager.getCmdGetMiss());
    assertEquals(1, this.statsManager.getCmdGets());
    assertEquals(0, this.statsManager.getCmdOffsets());
  }
  @SuppressWarnings({"ThrowableInstanceNeverThrown"})
  private void expectEvaluateCalled(
      final I_EncodeBusinessProcess mockBusinessProcess,
      final CleanableProcessExtByRef mockCleanableProcess,
      final CleanableProcessExtByRefBuilder mockCleanableProcessBuilder)
      throws Exception {

    File mockDirectoryFile = mockControl.createMock(File.class);
    I_GetConceptData mockRefset = mockControl.createMock(I_GetConceptData.class);

    EasyMock.expect(mockTerminologyWrapper.get()).andReturn(mockTermFactory);
    EasyMock.expect(mockBusinessProcess.getProperty(DIRECTORY_KEY)).andReturn(mockDirectoryFile);
    EasyMock.expect(mockBusinessProcess.getProperty(WORKING_REFSET_KEY)).andReturn(mockRefset);
    mockPropertyValidator.validate(mockDirectoryFile, "output directory");
    mockPropertyValidator.validate(mockRefset, "selected refset");

    EasyMock.expect(mockCleanableProcessBuilder.withTermFactory(mockTermFactory))
        .andReturn(mockCleanableProcessBuilder);
    EasyMock.expect(mockCleanableProcessBuilder.withSelectedDir(mockDirectoryFile))
        .andReturn(mockCleanableProcessBuilder);
    EasyMock.expect(mockCleanableProcessBuilder.withLogger(EasyMock.isA(Logger.class)))
        .andReturn(mockCleanableProcessBuilder);
    EasyMock.expect(mockCleanableProcessBuilder.build()).andReturn(mockCleanableProcess);
    I_ExtendByRef mockExt1 = mockControl.createMock(I_ExtendByRef.class);
    I_ExtendByRef mockExt2 = mockControl.createMock(I_ExtendByRef.class);
    EasyMock.expect(mockRefset.getConceptId()).andReturn(REFSET_CONCEPT_ID);
    // TODO fix this one
    // EasyMock.expect(mockTermFactory.getRefsetExtensionMembers(REFSET_CONCEPT_ID)).andReturn(Arrays.asList(mockExt1, mockExt2));

    mockCleanableProcess.processExtensionByReference(mockExt1);
    mockCleanableProcess.processExtensionByReference(mockExt2);
    EasyMock.expectLastCall().andThrow(new IllegalStateException());

    mockCleanableProcess.clean();
  }
  @Test(expected = Exception.class)
  public void testResolveDirectoryBeforeTimeout() throws LBInvocationException {
    LexBIGService lbs = EasyMock.createMock(LexBIGService.class);

    CodingSchemeRenderingList csrl = new CodingSchemeRenderingList();
    CodingSchemeRendering csr = new TimeoutCodingSchemeRendering();

    csrl.addCodingSchemeRendering(csr);

    EasyMock.expect(lbs.getSupportedCodingSchemes()).andReturn(csrl).anyTimes();
    EasyMock.replay(lbs);

    lexEvsCodeSystemVersionQuery.setLexBigService(lbs);
    codeSystemVersonDirectoryURIFactory.setLexBigService(lbs);

    CodeSystemVersionDirectoryURI directoryUri =
        lexEvsCodeSystemVersionQuery.getCodeSystemVersions();

    QueryControl queryControl = new QueryControl();
    queryControl.setTimeLimit(600l);

    CodeSystemVersionDirectory directory =
        lexEvsCodeSystemVersionQuery.resolve(directoryUri, queryControl, null);

    assertNotNull(directory);
  }
Ejemplo n.º 4
0
  /** tests {@link ToVectorAndPrefReducer} */
  @Test
  public void testToVectorAndPrefReducer() throws Exception {
    Reducer<VarIntWritable, VectorOrPrefWritable, VarIntWritable, VectorAndPrefsWritable>.Context
        context = EasyMock.createMock(Reducer.Context.class);

    context.write(
        EasyMock.eq(new VarIntWritable(1)),
        vectorAndPrefsWritableMatches(
            Arrays.asList(123L, 456L),
            Arrays.asList(1.0f, 2.0f),
            MathHelper.elem(3, 0.5),
            MathHelper.elem(7, 0.8)));

    EasyMock.replay(context);

    Vector similarityColumn = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    similarityColumn.set(3, 0.5);
    similarityColumn.set(7, 0.8);

    VectorOrPrefWritable itemPref1 = new VectorOrPrefWritable(123L, 1.0f);
    VectorOrPrefWritable itemPref2 = new VectorOrPrefWritable(456L, 2.0f);
    VectorOrPrefWritable similarities = new VectorOrPrefWritable(similarityColumn);

    new ToVectorAndPrefReducer()
        .reduce(new VarIntWritable(1), Arrays.asList(itemPref1, itemPref2, similarities), context);

    EasyMock.verify(context);
  }
  @Test
  public void testWriteEmptyFile() throws Exception {
    AbstractStreamWriteFilter<M> filter = createFilter();
    M message = createMessage(new byte[0]);

    WriteRequest writeRequest = new DefaultWriteRequest(message, new DummyWriteFuture());

    NextFilter nextFilter = EasyMock.createMock(NextFilter.class);
    /*
     * Record expectations
     */
    nextFilter.messageSent(session, writeRequest);

    /*
     * Replay.
     */
    EasyMock.replay(nextFilter);

    filter.filterWrite(nextFilter, session, writeRequest);

    /*
     * Verify.
     */
    EasyMock.verify(nextFilter);

    assertTrue(writeRequest.getFuture().isWritten());
  }
Ejemplo n.º 6
0
  public void getPeerStatusChangeHistory(
      DiscoveryServiceComponent component, List<DS_PeerStatusChange> historyList) {

    CommunityStatusProvider communityStatusProvider = getCommunityStatusProviders(component);
    ObjectDeployment cspObjectDeployment = getCommunityStatusProvidersObjectDeployment(component);

    CommunityStatusProviderClient cspClientMock =
        EasyMock.createMock(CommunityStatusProviderClient.class);

    // adding behavior
    cspClientMock.hereIsPeerStatusChangeHistory(
        DS_PeerStatusChangeHistoryMatcher.eqMatcher((historyList)), EasyMock.gt(0L));

    EasyMock.replay(cspClientMock);

    DeploymentID deploymentID =
        new DeploymentID(new ContainerID("dsClient", "dsServer", "peer", "dsClientPK"), "peer");
    AcceptanceTestUtil.publishTestObject(
        component, deploymentID, cspClientMock, CommunityStatusProviderClient.class);

    AcceptanceTestUtil.setExecutionContext(component, cspObjectDeployment, deploymentID);

    communityStatusProvider.getPeerStatusChangeHistory(cspClientMock, 0L);

    EasyMock.verify(cspClientMock);
  }
  /**
   * Tests when the contents of the file fits into one write buffer.
   *
   * @throws Exception when something goes wrong
   */
  @Test
  public void testWriteSingleBufferFile() throws Exception {
    byte[] data = new byte[] {1, 2, 3, 4};

    AbstractStreamWriteFilter<M> filter = createFilter();
    M message = createMessage(data);

    WriteRequest writeRequest = new DefaultWriteRequest(message, new DummyWriteFuture());

    NextFilter nextFilter = EasyMock.createMock(NextFilter.class);
    /*
     * Record expectations
     */
    nextFilter.filterWrite(
        EasyMock.eq(session), eqWriteRequest(new DefaultWriteRequest(IoBuffer.wrap(data))));
    nextFilter.messageSent(session, writeRequest);

    /*
     * Replay.
     */
    EasyMock.replay(nextFilter);

    filter.filterWrite(nextFilter, session, writeRequest);
    filter.messageSent(nextFilter, session, writeRequest);

    /*
     * Verify.
     */
    EasyMock.verify(nextFilter);

    assertTrue(writeRequest.getFuture().isWritten());
  }
  @Test
  public void testWriteWhileWriteInProgress() throws Exception {
    AbstractStreamWriteFilter<M> filter = createFilter();
    M message = createMessage(new byte[5]);

    Queue<WriteRequest> queue = new LinkedList<WriteRequest>();

    /*
     * Make up the situation.
     */
    session.setAttribute(filter.CURRENT_STREAM, message);
    session.setAttribute(filter.WRITE_REQUEST_QUEUE, queue);

    NextFilter nextFilter = EasyMock.createMock(NextFilter.class);
    /*
     * Replay.  (We recorded *nothing* because nothing should occur.)
     */
    EasyMock.replay(nextFilter);

    WriteRequest wr = new DefaultWriteRequest(new Object(), new DummyWriteFuture());
    filter.filterWrite(nextFilter, session, wr);
    assertEquals(1, queue.size());
    assertSame(wr, queue.poll());

    /*
     * Verify.
     */
    EasyMock.verify(nextFilter);

    session.removeAttribute(filter.CURRENT_STREAM);
    session.removeAttribute(filter.WRITE_REQUEST_QUEUE);
  }
  @Test
  public void testUnsafeAOFileNonExistent() throws Exception {
    expect(mockBeanFactory.getInstance(currentUser)).andReturn(mockI18nHelper).anyTimes();
    expect(mockPermissionManager.hasPermission(Permissions.SYSTEM_ADMIN, currentUser))
        .andReturn(true);
    expect(
            mockI18nHelper.getText(
                EasyMock.eq("admin.errors.could.not.find.file"), EasyMock.<String>anyObject()))
        .andReturn("File does not exist.");

    final File file = File.createTempFile("testUnsafeAOFileNonExistent", "txt");
    file.deleteOnExit();

    try {
      final DataImportParams params =
          new DataImportParams.Builder(null)
              .setUnsafeJiraBackup(file)
              .setUnsafeAOBackup(
                  new File("I.really.really.don't.exist.and.if.i.did.it.would.be.very.unlucky"))
              .build();
      executeTest(params, false, DataImportService.ImportError.NONE);
      fail("Calling doImport with invalid validation result should have thrown an exception!");
    } catch (IllegalStateException e) {
      // yay
    } finally {
      file.delete();
    }
  }
  /**
   * Tests that the filter just passes objects which aren't FileRegion's through to the next filter.
   *
   * @throws Exception when something goes wrong
   */
  @Test
  public void testWriteNonFileRegionMessage() throws Exception {
    AbstractStreamWriteFilter<M> filter = createFilter();

    Object message = new Object();
    WriteRequest writeRequest = new DefaultWriteRequest(message, new DummyWriteFuture());

    NextFilter nextFilter = EasyMock.createMock(NextFilter.class);
    /*
     * Record expectations
     */
    nextFilter.filterWrite(session, writeRequest);
    nextFilter.messageSent(session, writeRequest);

    /*
     * Replay.
     */
    EasyMock.replay(nextFilter);

    filter.filterWrite(nextFilter, session, writeRequest);
    filter.messageSent(nextFilter, session, writeRequest);

    /*
     * Verify.
     */
    EasyMock.verify(nextFilter);
  }
  public void testEnactReportWorkflow() {
    long processId = 5;
    StudyParticipantAssignment assignment = Fixtures.createAssignment();
    ExpeditedAdverseEventReport aeReport = Fixtures.createSavableExpeditedReport();
    Report report = Fixtures.createReport("testReport");
    aeReport.setId(55);
    AdverseEventReportingPeriod reportingPeriod = Fixtures.createReportingPeriod();
    WorkflowConfig workflowConfig = Fixtures.createWorkflowConfig("test");
    StudySite site = assignment.getStudySite();
    StudySiteWorkflowConfig ssWfCfg = new StudySiteWorkflowConfig("report", site, workflowConfig);
    site.addStudySiteWorkflowConfig(ssWfCfg);
    reportingPeriod.addAeReport(aeReport);
    aeReport.setAssignment(assignment);
    aeReport.addReport(report);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(WorkflowService.VAR_STUDY_ID, site.getStudy().getId());
    variables.put(WorkflowService.VAR_WF_TYPE, Report.class.getName());
    variables.put(WorkflowService.VAR_REPORT_ID, report.getId());
    variables.put(WorkflowService.VAR_EXPEDITED_REPORT_ID, aeReport.getId());
    variables.put(WorkflowService.VAR_WF_STUDY_NAME, reportingPeriod.getStudy().getDisplayName());
    variables.put(
        WorkflowService.VAR_WF_SUBJECT_NAME, reportingPeriod.getParticipant().getFullName());
    variables.put(WorkflowService.VAR_WF_COURSE_NAME, reportingPeriod.getName());

    EasyMock.expect(wfService.createProcessInstance("test", variables)).andReturn(processInstance);
    EasyMock.expect(processInstance.getId()).andReturn(processId).anyTimes();
    reportDao.save(report);
    replayMocks();
    impl.enactReportWorkflow(report);
    verifyMocks();
  }
  public void testEnactReportingPeriodWorkflow() {
    long processId = 5;
    StudyParticipantAssignment assignment = Fixtures.createAssignment();
    AdverseEventReportingPeriod reportingPeriod = Fixtures.createReportingPeriod();
    reportingPeriod.setId(44);
    WorkflowConfig workflowConfig = Fixtures.createWorkflowConfig("test");
    StudySite site = assignment.getStudySite();
    StudySiteWorkflowConfig ssWfCfg =
        new StudySiteWorkflowConfig("reportingPeriod", site, workflowConfig);
    site.addStudySiteWorkflowConfig(ssWfCfg);
    reportingPeriod.setAssignment(assignment);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(WorkflowService.VAR_STUDY_ID, site.getStudy().getId());
    variables.put(WorkflowService.VAR_WF_TYPE, AdverseEventReportingPeriod.class.getName());
    variables.put(WorkflowService.VAR_WF_STUDY_NAME, reportingPeriod.getStudy().getDisplayName());
    variables.put(
        WorkflowService.VAR_WF_SUBJECT_NAME, reportingPeriod.getParticipant().getFullName());
    variables.put(WorkflowService.VAR_WF_COURSE_NAME, reportingPeriod.getName());
    variables.put(WorkflowService.VAR_REPORTING_PERIOD_ID, reportingPeriod.getId());

    EasyMock.expect(wfService.createProcessInstance("test", variables)).andReturn(processInstance);
    EasyMock.expect(processInstance.getId()).andReturn(processId).anyTimes();
    rpDao.modifyOrSaveReviewStatusAndComments(reportingPeriod);
    replayMocks();
    impl.enactReportingPeriodWorkflow(reportingPeriod);
    verifyMocks();
  }
  public void testAdvanceReportWorkflow() {
    Integer id = 10;
    Integer wfId = 5;
    String transitionToTake = "abcd";
    String loginId = "SYSTEM_ADMIN";
    ReviewStatus reviewStatus = ReviewStatus.DRAFT_INCOMPLETE;
    Report report = Fixtures.createReport("testReport");
    report.setStatus(ReportStatus.INPROCESS);
    report.setReviewComments(new ArrayList<ReportReviewComment>());
    report.setWorkflowId(wfId);
    List<String> transitions = new ArrayList<String>();

    ReportSubmittability errorMessagesMock = registerMockFor(ReportSubmittability.class);
    EasyMock.expect(errorMessagesMock.isSubmittable()).andReturn(true);
    EasyMock.expect(reportValidationService.isSubmittable(report)).andReturn(errorMessagesMock);
    EasyMock.expect(wfService.nextTransitionNames(wfId, loginId)).andReturn(transitions);
    EasyMock.expect(wfService.advanceWorkflow(wfId, transitionToTake)).andReturn(reviewStatus);
    EasyMock.expect(reportDao.getById(id)).andReturn(report);
    reportDao.save(report);
    replayMocks();
    List<String> transitionsNames = impl.advanceReportWorkflow(wfId, transitionToTake, id, loginId);

    verifyMocks();
    assertEquals(
        "A review comment for the action of advancing workflow was not added",
        1,
        report.getReviewCommentsInternal().size());
  }
  /** tests {@link MostSimilarItemPairsMapper} */
  public void testMostSimilarItemsPairsMapper() throws Exception {

    OpenIntLongHashMap indexItemIDMap = new OpenIntLongHashMap();
    indexItemIDMap.put(12, 12L);
    indexItemIDMap.put(34, 34L);
    indexItemIDMap.put(56, 56L);

    Mapper<IntWritable, VectorWritable, EntityEntityWritable, DoubleWritable>.Context context =
        EasyMock.createMock(Mapper.Context.class);

    context.write(new EntityEntityWritable(34L, 56L), new DoubleWritable(0.9));

    EasyMock.replay(context);

    Vector vector = new RandomAccessSparseVector(Integer.MAX_VALUE);
    vector.set(12, 0.2);
    vector.set(34, 1.0);
    vector.set(56, 0.9);

    MostSimilarItemPairsMapper mapper = new MostSimilarItemPairsMapper();
    setField(mapper, "indexItemIDMap", indexItemIDMap);
    setField(mapper, "maxSimilarItemsPerItem", 1);

    mapper.map(new IntWritable(34), new VectorWritable(vector), context);

    EasyMock.verify(context);
  }
Ejemplo n.º 15
0
  @Test
  public void testBasic() throws Exception {
    ServiceHandler handler = new ServiceHandler();
    Service service = new Service();
    handler.registerWebService(service);

    Request baseRequest = org.easymock.classextension.EasyMock.createMock(Request.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpServletResponse response = createMock(HttpServletResponse.class);

    expect(baseRequest.isHandled()).andReturn(false);
    expect(request.getMethod()).andReturn("GET");
    expect(request.getPathInfo()).andReturn("/");
    expect(request.getParameter("bar")).andReturn("bar2");
    expect(request.getParameter("baz")).andReturn(null);
    expect(request.getHeader("Content-Length")).andReturn("103");
    expect(response.isCommitted()).andReturn(false).anyTimes();
    baseRequest.setHandled(true);

    org.easymock.classextension.EasyMock.replay(baseRequest);
    replay(request, response);
    handler.handle(null, baseRequest, request, response);
    org.easymock.classextension.EasyMock.verify(baseRequest);
    verify(request, response);
  }
Ejemplo n.º 16
0
  /**
   * tests {@link UserVectorSplitterMapper} in the special case that some userIDs shall be excluded
   */
  @Test
  public void testUserVectorSplitterMapperUserExclusion() throws Exception {
    Mapper<VarLongWritable, VectorWritable, VarIntWritable, VectorOrPrefWritable>.Context context =
        EasyMock.createMock(Mapper.Context.class);

    context.write(
        EasyMock.eq(new VarIntWritable(34)), prefOfVectorOrPrefWritableMatches(123L, 0.5f));
    context.write(
        EasyMock.eq(new VarIntWritable(56)), prefOfVectorOrPrefWritableMatches(123L, 0.7f));

    EasyMock.replay(context);

    FastIDSet usersToRecommendFor = new FastIDSet();
    usersToRecommendFor.add(123L);

    UserVectorSplitterMapper mapper = new UserVectorSplitterMapper();
    setField(mapper, "maxPrefsPerUserConsidered", 10);
    setField(mapper, "usersToRecommendFor", usersToRecommendFor);

    RandomAccessSparseVector vector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
    vector.set(34, 0.5);
    vector.set(56, 0.7);

    mapper.map(new VarLongWritable(123L), new VectorWritable(vector), context);
    mapper.map(new VarLongWritable(456L), new VectorWritable(vector), context);

    EasyMock.verify(context);
  }
  @Test
  public void testTerminalClauseTwoSearchHandlersDifferent() throws Exception {
    final TerminalClause input1 = new TerminalClauseImpl("field", Operator.EQUALS, "Value1");
    final TerminalClause input2 = new TerminalClauseImpl("field", Operator.EQUALS, "Value2");
    final SearchHandlerManager manager = mockController.getMock(SearchHandlerManager.class);

    final ClausePermissionHandler permissionHandler =
        mockController.getMock(ClausePermissionHandler.class);
    EasyMock.expect(permissionHandler.sanitise(null, input1)).andReturn(input1);
    EasyMock.expect(permissionHandler.sanitise(null, input1)).andReturn(input2);

    final ClauseHandler handler1 = new MockClauseHandler(null, null, permissionHandler, null);
    final ClauseHandler handler2 = new MockClauseHandler(null, null, permissionHandler, null);

    EasyMock.expect(manager.getClauseHandler((User) null, "field"))
        .andReturn(CollectionBuilder.newBuilder(handler1, handler2).asList());

    final JqlOperandResolver jqlOperandResolver = mockController.getMock(JqlOperandResolver.class);

    mockController.replay();

    ClauseSanitisingVisitor visitor =
        new ClauseSanitisingVisitor(manager, jqlOperandResolver, null) {
          @Override
          TerminalClause sanitiseOperands(final TerminalClause clause) {
            return clause;
          }
        };

    final Clause expected = new OrClause(input1, input2);
    final Clause clause = input1.accept(visitor);
    assertEquals(expected, clause);

    mockController.verify();
  }
  @Test
  public void testTerminalClauseOneSearchHandler() throws Exception {
    final TerminalClause input = new TerminalClauseImpl("field", Operator.EQUALS, "Value");
    final SearchHandlerManager manager = mockController.getMock(SearchHandlerManager.class);

    final ClausePermissionHandler permissionHandler =
        mockController.getMock(ClausePermissionHandler.class);
    EasyMock.expect(permissionHandler.sanitise(null, input)).andReturn(input);

    final ClauseHandler handler = new MockClauseHandler(null, null, permissionHandler, null);
    EasyMock.expect(manager.getClauseHandler((User) null, "field"))
        .andReturn(Collections.singletonList(handler));

    final JqlOperandResolver jqlOperandResolver = mockController.getMock(JqlOperandResolver.class);

    mockController.replay();

    ClauseSanitisingVisitor visitor =
        new ClauseSanitisingVisitor(manager, jqlOperandResolver, null) {
          @Override
          TerminalClause sanitiseOperands(final TerminalClause clause) {
            return clause;
          }
        };

    final Clause clause = input.accept(visitor);
    assertSame(clause, input);

    mockController.verify();
  }
  @Test
  public void testInitializationSecondSucceeded() throws Exception {
    DateTime expectedStartTime = new DateTime(0);

    EasyMock.expect(mockFlow1.getName()).andReturn("a").once();
    EasyMock.expect(mockFlow2.getName()).andReturn("b").once();

    EasyMock.expect(mockFlow1.getStatus()).andReturn(Status.READY).times(3);
    EasyMock.expect(mockFlow2.getStatus()).andReturn(Status.SUCCEEDED).times(3);

    EasyMock.expect(mockFlow1.getStartTime()).andReturn(null).once();
    EasyMock.expect(mockFlow2.getStartTime()).andReturn(expectedStartTime).once();

    EasyMock.expect(mockFlow2.getParentProps()).andReturn(props).once();

    EasyMock.expect(mockFlow1.getName()).andReturn("1").once();
    EasyMock.expect(mockFlow2.getName()).andReturn("2").once();

    EasyMock.replay(mockFlow1, mockFlow2, props);

    flow = new GroupedExecutableFlow("blah", mockFlow1, mockFlow2);

    Assert.assertEquals(Status.READY, flow.getStatus());
    Assert.assertEquals(expectedStartTime, flow.getStartTime());
    Assert.assertEquals(null, flow.getEndTime());
    // <<<<<<< HEAD:azkaban/src/unit/azkaban/flow/GroupedExecutableFlowTest.java
    Assert.assertEquals(emptyExceptions, flow.getExceptions());
    Assert.assertEquals(props, flow.getParentProps());
  }
  @Test
  public void testAllBaseJobsCompleted() throws Exception {
    EasyMock.replay(mockFlow1, mockFlow2, props);

    final JobManager factory = EasyMock.createStrictMock(JobManager.class);
    EasyMock.replay(factory);

    final IndividualJobExecutableFlow completedJob1 =
        new IndividualJobExecutableFlow("blah", "blah", factory);
    final IndividualJobExecutableFlow completedJob2 =
        new IndividualJobExecutableFlow("blah", "blah", factory);

    flow = new GroupedExecutableFlow("blah", completedJob1, completedJob2);

    completedJob1.markCompleted();
    completedJob2.markCompleted();

    AtomicBoolean callbackWasCalled = new AtomicBoolean(false);
    flow.execute(
        props,
        new OneCallFlowCallback(callbackWasCalled) {
          @Override
          public void theCallback(Status status) {
            Assert.assertEquals(Status.SUCCEEDED, status);
          }
        });

    Assert.assertTrue("Callback wasn't called!?", callbackWasCalled.get());
    EasyMock.verify(factory);
  }
 private void mockFetchManagerRestartAnyTimes() throws InterruptedException {
   this.fetchManager.stopFetchRunner();
   EasyMock.expectLastCall().anyTimes();
   this.fetchManager.resetFetchState();
   EasyMock.expectLastCall().anyTimes();
   this.fetchManager.startFetchRunner();
   EasyMock.expectLastCall().anyTimes();
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mockUser = new MockUser("admin");
   ctx = EasyMock.createNiceMock(JiraAuthenticationContext.class);
   prms = EasyMock.createNiceMock(PermissionManager.class);
   proj = createNiceMock(ProjectManager.class);
 }
Ejemplo n.º 23
0
 public SmsBuilder aboutPurchase(String amount) {
   EasyMock.expect(anySmsMessage.getDisplayMessageBody())
       .andReturn(
           String.format(
               "You have done a debit purchase of INR %s at ARJAY RETAIL SONY BANGALORE.Available balance as on Jan 6 2010 8:45 PM IST is INR 10,000.00",
               amount));
   EasyMock.expectLastCall().anyTimes();
   return this;
 }
 private BapPublisher createAndAddMockPublisher(final String hostConfigurationName) {
   final BapPublisher mockPublisher = mockControl.createMock(BapPublisher.class);
   if (hostConfigurationName != null) {
     mockPublisher.setEffectiveEnvironmentInBuildInfo(
         (AbstractBuild) EasyMock.anyObject(), (BPBuildInfo) EasyMock.anyObject());
     EasyMock.expect(mockPublisher.getConfigName()).andReturn(hostConfigurationName);
   }
   publishers.add(mockPublisher);
   return mockPublisher;
 }
 @Test
 public void rollbackShouldRollback() {
   GeonamesAdm3Importer geonamesAdm3Importer = new GeonamesAdm3Importer();
   IAdmDao admDao = EasyMock.createMock(IAdmDao.class);
   EasyMock.expect(admDao.deleteAllByLevel(3)).andReturn(4);
   EasyMock.replay(admDao);
   geonamesAdm3Importer.setAdmDao(admDao);
   List<NameValueDTO<Integer>> deleted = geonamesAdm3Importer.rollback();
   assertEquals(1, deleted.size());
   assertEquals(4, deleted.get(0).getValue().intValue());
 }
Ejemplo n.º 26
0
  /** tests {@link ItemIDIndexMapper} */
  @Test
  public void testItemIDIndexMapper() throws Exception {
    Mapper<LongWritable, Text, VarIntWritable, VarLongWritable>.Context context =
        EasyMock.createMock(Mapper.Context.class);

    context.write(new VarIntWritable(TasteHadoopUtils.idToIndex(789L)), new VarLongWritable(789L));
    EasyMock.replay(context);

    new ItemIDIndexMapper().map(new LongWritable(123L), new Text("456,789,5.0"), context);

    EasyMock.verify(context);
  }
Ejemplo n.º 27
0
 JMSFault setupJMSFault(boolean isSender, QName code, Object detail) {
   jmsFault = control.createMock(JMSFault.class);
   EasyMock.expect(jmsFault.getReason()).andReturn("reason");
   EasyMock.expect(jmsFault.isSender()).andReturn(isSender);
   EasyMock.expect(jmsFault.getSubCode()).andReturn(code);
   if (null != detail) {
     EasyMock.expect(jmsFault.getDetail()).andReturn(detail);
     JMSFaultType sft = new JMSFaultType();
     sft.setFaultCode(SoapJMSConstants.getContentTypeMismatchQName());
   }
   return jmsFault;
 }
  /** tests {@link CountUsersMapper} */
  public void testCountUsersMapper() throws Exception {
    Mapper<LongWritable, Text, CountUsersKeyWritable, VarLongWritable>.Context context =
        EasyMock.createMock(Mapper.Context.class);
    context.write(keyForUserID(12L), EasyMock.eq(new VarLongWritable(12L)));
    context.write(keyForUserID(35L), EasyMock.eq(new VarLongWritable(35L)));
    EasyMock.replay(context);

    CountUsersMapper mapper = new CountUsersMapper();
    mapper.map(null, new Text("12,100,1.3"), context);
    mapper.map(null, new Text("35,100,3.0"), context);

    EasyMock.verify(context);
  }
 private void mockLoadNullInitOffset(
     final String topic, final String group, final Partition partition) {
   EasyMock.expect(
           this.offsetStorage.load(
               EasyMock.eq(topic), EasyMock.contains(group), EasyMock.eq(partition)))
       .andReturn(null);
   this.offsetStorage.initOffset(
       EasyMock.eq(topic), EasyMock.contains(group), EasyMock.eq(partition), EasyMock.eq(0L));
   EasyMock.expectLastCall();
 }
Ejemplo n.º 30
0
  /** tests {@link ToItemPrefsMapper} */
  @Test
  public void testToItemPrefsMapper() throws Exception {
    Mapper<LongWritable, Text, VarLongWritable, VarLongWritable>.Context context =
        EasyMock.createMock(Mapper.Context.class);

    context.write(new VarLongWritable(12L), new EntityPrefWritable(34L, 1.0f));
    context.write(new VarLongWritable(56L), new EntityPrefWritable(78L, 2.0f));
    EasyMock.replay(context);

    ToItemPrefsMapper mapper = new ToItemPrefsMapper();
    mapper.map(new LongWritable(123L), new Text("12,34,1"), context);
    mapper.map(new LongWritable(456L), new Text("56,78,2"), context);

    EasyMock.verify(context);
  }