@Test public void writeBodySync() throws Exception { PDDocument document = mock(PDDocument.class); COSDocument cosDoc = mock(COSDocument.class); FileTrailer trailer = new FileTrailer(); when(document.getDocument()).thenReturn(cosDoc); when(cosDoc.getTrailer()).thenReturn(trailer); this.victim = new PDDocumentWriter(from(new DevNullWritableByteChannel()), null, WriteOption.SYNC_BODY_WRITE); TestUtils.setProperty(victim, "writer", this.writer); ArgumentCaptor<PDFBodyWriter> bodyWriter = ArgumentCaptor.forClass(PDFBodyWriter.class); victim.write(document); verify(cosDoc).accept(bodyWriter.capture()); assertThat(bodyWriter.getValue().objectsWriter, new InstanceOf(SyncPDFBodyObjectsWriter.class)); }
@Test public void writeBodyCompressed() throws Exception { PDDocument document = mock(PDDocument.class); COSDocument cosDoc = mock(COSDocument.class); FileTrailer trailer = new FileTrailer(); when(document.getDocument()).thenReturn(cosDoc); when(cosDoc.getTrailer()).thenReturn(trailer); this.victim = new PDDocumentWriter(from(new DevNullWritableByteChannel()), null, WriteOption.SYNC_BODY_WRITE, WriteOption.OBJECT_STREAMS); TestUtils.setProperty(victim, "writer", this.writer); ArgumentCaptor<PDFBodyWriter> bodyWriter = ArgumentCaptor.forClass(PDFBodyWriter.class); victim.write(document); verify(cosDoc).accept(bodyWriter.capture()); assertThat(bodyWriter.getValue().objectsWriter, new InstanceOf(ObjectsStreamPDFBodyObjectsWriter.class)); }
public JoynrEnd2EndTest() { Answer<AbstractSubscriptionPublisher> answer = new Answer<AbstractSubscriptionPublisher>() { @Override public AbstractSubscriptionPublisher answer(InvocationOnMock invocation) throws Throwable { Object provider = invocation.getArguments()[0]; if (provider instanceof testProvider) { ((testProvider) provider).setSubscriptionPublisher(testSubscriptionPublisher); } return testSubscriptionPublisher; } }; Mockito.doAnswer(answer) .when(subscriptionPublisherFactory) .create((JoynrProvider) Mockito.argThat(new InstanceOf(testProvider.class))); }
@Test public void testGetNullKey() throws Exception { bucket = createCache(); try { bucket.get(null, SimpleObject.class); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testGetNullType() throws Exception { bucket = createCache(); try { bucket.get("TEST_KEY", null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("typeOfT is null", e.getMessage()); } }
@Test public void testPutNullKey() throws Exception { bucket = createCache(); try { bucket.put(null, new SimpleObject("TEST_VALUE")); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testPutNullObject() throws Exception { bucket = createCache(); try { bucket.put("TEST_KEY", null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("object is null", e.getMessage()); } }
@Test public void testContainsNullKey() throws Exception { bucket = createCache(); try { bucket.contains(null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testRemoveNullKey() throws Exception { bucket = createCache(); try { bucket.remove(null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testGetAsyncNullKey() throws Exception { bucket = createCache(); try { bucket.getAsync(null, SimpleObject.class, null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testGetAsyncNullType() throws Exception { bucket = createCache(); try { bucket.getAsync("TEST_KEY", null, null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("typeOfT is null", e.getMessage()); } }
@Test public void testPutAsyncNullKey() throws Exception { bucket = createCache(); try { bucket.putAsync(null, new SimpleObject("TEST_VALUE"), null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testPutAsyncNullObject() throws Exception { bucket = createCache(); try { bucket.putAsync("TEST_KEY", null, null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("object is null", e.getMessage()); } }
@Test public void testContainsAsyncNullKey() throws Exception { bucket = createCache(); try { bucket.containsAsync(null, null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testRemoveAsyncNullKey() throws Exception { bucket = createCache(); try { bucket.removeAsync(null, null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testGetRxKey() throws Exception { bucket = createCache(); try { bucket.getRx(null, SimpleObject.class); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testGetRxNullType() throws Exception { bucket = createCache(); try { bucket.getRx("TEST_KEY", null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("typeOfT is null", e.getMessage()); } }
@Test public void testPutRxNullKey() throws Exception { bucket = createCache(); try { bucket.putRx(null, new SimpleObject("TEST_VALUE")); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testPutRxNullObject() throws Exception { bucket = createCache(); try { bucket.putRx("TEST_KEY", null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("object is null", e.getMessage()); } }
@Test public void testContainsRxNullKey() throws Exception { bucket = createCache(); try { bucket.containsRx(null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void testRemoveRxNullKey() throws Exception { bucket = createCache(); try { bucket.removeRx(null); fail("Should throw an exception"); } catch (Exception e) { assertThat(e, new InstanceOf(IllegalArgumentException.class)); assertEquals("key is null or empty", e.getMessage()); } }
@Test public void writeBodyAsync() throws Exception { PDDocument document = mock(PDDocument.class); COSDocument cosDoc = mock(COSDocument.class); FileTrailer trailer = new FileTrailer(); when(document.getDocument()).thenReturn(cosDoc); when(cosDoc.getTrailer()).thenReturn(trailer); ArgumentCaptor<PDFBodyWriter> bodyWriter = ArgumentCaptor.forClass(PDFBodyWriter.class); victim.write(document); verify(cosDoc).accept(bodyWriter.capture()); assertThat(bodyWriter.getValue().objectsWriter, new InstanceOf(AsyncPDFBodyObjectsWriter.class)); }
@Test public void testFetchUserInRandosParsing() throws Exception { OnFetchUser onFetchUseMock = spy(new OnFetchUserAssertions()); new UserFetchResultListener(context, onFetchUseMock).onResponse(APITestHelper.getUserFetchJSONObject()); verify(onFetchUseMock, times(1)).onFetch((User) argThat(new InstanceOf(User.class))); }