Package org.mockito.stubbing

Examples of org.mockito.stubbing.Answer


        assertThatNoTemporariesRemain();
    }

    private void installFromZip() throws IOException {
        final File content = ZipFileMother.createContentFileForZip(stagingFolder.getRoot());
        Mockito.doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                File targetFolder = (File) invocation.getArguments()[0];
                ZipFileMother.createZipFileInTemporaryFolder(targetFolder, "iAmA.zip", content);
                return null;
View Full Code Here


    }

    @Test
    public void forwardsNonZipDataDirectlyToWrapped() throws Exception {
        final File[] createdFile = new File[1];
        Mockito.doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                File targetFolder = (File) invocation.getArguments()[0];
                File notAZip = createFileInTemporaryFolder(targetFolder, "iAmNotAZip.jar");
                createdFile[0] = notAZip;
View Full Code Here

    }

    @Test
    public void deletesFilesOnceForwarded() throws Exception {
        final File[] createdFile = new File[1];
        Mockito.doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                File targetFolder = (File) invocation.getArguments()[0];
                File notAZip = createFileInTemporaryFolder(targetFolder, "iAmNotAZip.jar");
                createdFile[0] = notAZip;
View Full Code Here

        when(containerRequest.getHeaderValue(SecurityContextFilter.HEADER_DATE)).thenReturn(dateString);
        when(containerRequest.getHeaderValue(SecurityContextFilter.HEADER_NONCE)).thenReturn("123");
        when(containerRequest.getPath()).thenReturn("user/555");
        when(containerRequest.getMethod()).thenReturn("POST");
        when(userRepository.findByUuid(user.getUuid().toString())).thenReturn(user);
        doAnswer(new Answer() {

            public Object answer(InvocationOnMock invocation) throws Throwable {
                SecurityContext context = (SecurityContext) invocation.getArguments()[0];
                ExternalUser user = (ExternalUser) context.getUserPrincipal();
                assertThat(user.getId(), is(externalUser.getId()));
View Full Code Here

            add("s3n://foo-bar/pathoDromic");
        }}));
    }

    private void mockS3Client() {
        when(s3Client.listObjects(any(ListObjectsRequest.class))).thenAnswer(new Answer() {

            @Override
            public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                Object[] args=invocationOnMock.getArguments();
                ListObjectsRequest r=(ListObjectsRequest) args[0];
View Full Code Here

      protected QueueACLsManager createQueueACLsManager(
          ResourceScheduler scheduler,
          Configuration conf) {
        QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
        when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
            any(QueueACL.class), anyString())).thenAnswer(new Answer() {
          public Object answer(InvocationOnMock invocation) {
            return isQueueUser;
          }
        });
        return mockQueueACLsManager;
View Full Code Here

        loader.put(p);
        loader.flushcache();
      }

      HRegion spyR = spy(r);
      doAnswer(new Answer() {
        public Object answer(InvocationOnMock invocation) throws Throwable {
          r.writestate.writesEnabled = false;
          return invocation.callRealMethod();
        }
      }).when(spyR).doRegionCompactionPrep();
View Full Code Here

   private void addBlockingLocalTopologyManager(final EmbeddedCacheManager manager, final CheckPoint checkPoint,
                                                final int currentTopologyId)
         throws InterruptedException {
      LocalTopologyManager component = TestingUtil.extractGlobalComponent(manager, LocalTopologyManager.class);
      LocalTopologyManager spyLtm = Mockito.spy(component);
      doAnswer(new Answer() {
         @Override
         public Object answer(InvocationOnMock invocation) throws Throwable {
            CacheTopology topology = (CacheTopology) invocation.getArguments()[1];
            // Ignore the first topology update on the joiner, which is with the topology before the join
            if (topology.getTopologyId() != currentTopologyId) {
View Full Code Here

   private void addBlockingLocalTopologyManager(final EmbeddedCacheManager manager, final CheckPoint checkPoint,
                                                final int currentTopologyId)
         throws InterruptedException {
      LocalTopologyManager component = TestingUtil.extractGlobalComponent(manager, LocalTopologyManager.class);
      LocalTopologyManager spyLtm = Mockito.spy(component);
      doAnswer(new Answer() {
         @Override
         public Object answer(InvocationOnMock invocation) throws Throwable {
            CacheTopology topology = (CacheTopology) invocation.getArguments()[1];
            // Ignore the first topology update on the joiner, which is with the topology before the join
            if (topology.getTopologyId() != currentTopologyId) {
View Full Code Here

   private void blockEntryCommit(final CheckPoint checkPoint, AdvancedCache<Object, Object> cache) {
      ClusteringDependentLogic cdl1 = cache.getComponentRegistry().getComponent(ClusteringDependentLogic.class);
      ClusteringDependentLogic spyCdl1 = spy(cdl1);
      TestingUtil.replaceComponent(cache, ClusteringDependentLogic.class, spyCdl1, true);
      doAnswer(new Answer() {
         @Override
         public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            CacheEntry entry = (CacheEntry) arguments[0];
            Object key = entry.getKey();
View Full Code Here

TOP

Related Classes of org.mockito.stubbing.Answer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.