Examples of Answer


Examples of org.mockito.stubbing.Answer

        if(arguments != null && !arguments.isEmpty())
        {
            when(queue.getAvailableAttributes()).thenReturn(arguments.keySet());
            final ArgumentCaptor<String> requestedAttribute = ArgumentCaptor.forClass(String.class);
            when(queue.getAttribute(requestedAttribute.capture())).then(
                    new Answer()
                    {

                        @Override
                        public Object answer(final InvocationOnMock invocation) throws Throwable
                        {
View Full Code Here

Examples of org.mockito.stubbing.Answer

        // collect a list of all service registrations to validate that they are all unregistered on shutdown
        when(bundleContext.registerService(anyString(), anyObject(), any(Dictionary.class))).thenAnswer(new Answer<ServiceRegistration>() {
            public ServiceRegistration answer(InvocationOnMock invocation) {
                final ServiceRegistration mockRegistration = mock(ServiceRegistration.class);
                serviceRegistrations.add(mockRegistration);
                doAnswer(new Answer() {
                    public Object answer(InvocationOnMock invocation) {
                        return serviceRegistrations.remove(mockRegistration);
                    }
                }).when(mockRegistration).unregister();
                return mockRegistration;
View Full Code Here

Examples of org.mockito.stubbing.Answer

  public void deletesVersionIfErrorsOccurDuringTransfer() throws Exception {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    NumericVersion version = new NumericVersion(5, 0, 4);
    Installation installation = mock(Installation.class);
    doThrow(new RuntimeException()).when(installation).addContent(isA(DataInVersion.class));
    doAnswer(new Answer() {
      @Override
      public Object answer(InvocationOnMock invocation) throws Throwable {
        countDownLatch.countDown();
        return null;
      }
View Full Code Here

Examples of org.mockito.stubbing.Answer

    }

    private BundleContext createMockBundleContext()
    {
        BundleContext result = (BundleContext) Mockito.mock(BundleContext.class);
        Mockito.when(result.getProperty(Matchers.anyString())).thenAnswer(new Answer()
        {
            public Object answer(InvocationOnMock invocation) throws Throwable
            {
                String prop = (String) invocation.getArguments()[0];
View Full Code Here

Examples of org.mockito.stubbing.Answer

    doNothing().when(mockProcessor).setup(any(InputStream.class));
    doThrow(new IOException()).
            doThrow(new IOException()).
            doThrow(new IOException()).
            doAnswer(new Answer() {
              @Override
              public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                latch.countDown();
                return null;
              }
View Full Code Here

Examples of org.mockito.stubbing.Answer

            .thenReturn(HttpConstants.Codes.UNAUTHORIZED)
            .thenReturn(HttpConstants.Codes.SERVICE_UNAVAILABLE)
            .thenReturn(HttpConstants.Codes.SUCCESS);

    // turn off the client when we start processing
    doAnswer(new Answer() {
      @Override
      public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
        latch.countDown();
        return null;
      }
View Full Code Here

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

Examples of org.mockito.stubbing.Answer

    }

    @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

Examples of org.mockito.stubbing.Answer

    }

    @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

Examples of org.mockito.stubbing.Answer

        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
TOP
Copyright © 2018 www.massapi.com. 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.