Refine search
@Test public void byteArrayToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer convert = this.conversionService.convert(bytes, ByteBuffer.class); assertThat(convert.array(), not(sameInstance(bytes))); assertThat(convert.array(), equalTo(bytes)); }
public void check() { TestCls v = new TestCls(); v.a = 3; map.put("a", v); Iterable<TestCls> it = test("a"); TestCls next = it.iterator().next(); assertThat(next, sameInstance(v)); assertThat(next.a, is(4)); } }
@Test public void currentAttributes() { SimpAttributesContextHolder.setAttributes(this.simpAttributes); assertThat(SimpAttributesContextHolder.currentAttributes(), sameInstance(this.simpAttributes)); }
@Test public void getAttributes() { assertThat(SimpAttributesContextHolder.getAttributes(), nullValue()); SimpAttributesContextHolder.setAttributes(this.simpAttributes); assertThat(SimpAttributesContextHolder.getAttributes(), sameInstance(this.simpAttributes)); }
@Test public void byteBufferToByteArray() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); byte[] convert = this.conversionService.convert(byteBuffer, byte[].class); assertThat(convert, not(sameInstance(bytes))); assertThat(convert, equalTo(bytes)); }
@Test public void shouldAllowForChainedCallsToSendIfFailed() { assertThat(SUCCESS_WITH_VALUE.ifSucceededSendTo(mockReceiver), sameInstance(SUCCESS_WITH_VALUE)); }
@Test public void byteBufferToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); ByteBuffer convert = this.conversionService.convert(byteBuffer, ByteBuffer.class); assertThat(convert, not(sameInstance(byteBuffer.rewind()))); assertThat(convert, equalTo(byteBuffer.rewind())); assertThat(convert, equalTo(ByteBuffer.wrap(bytes))); assertThat(convert.array(), equalTo(bytes)); }
@Test public void shouldReturnFailureForMapOfFailed() { assertThat(FAILURE_WITH_THROWABLE.ifSucceededMap(mockValueFunction), sameInstance(FAILURE_WITH_THROWABLE)); verifyZeroInteractions(mockValueFunction); }
@Test public void byteBufferToOtherType() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); OtherType convert = this.conversionService.convert(byteBuffer, OtherType.class); assertThat(convert.bytes, not(sameInstance(bytes))); assertThat(convert.bytes, equalTo(bytes)); }
@Test public void shouldReturnOtherResultForOrAttemptGetFromOfFailure() { assertThat(FAILURE_WITH_THROWABLE.orAttemptGetFrom(mockOtherValueFailingAttemptSupplier), sameInstance(FAILURE)); }
@Test public void getSessionMutex() { assertThat(this.simpAttributes.getSessionMutex(), sameInstance(this.map)); }
@Test public void shouldAllowForChainedCallsToBind() { assertThat(SUCCESS_WITH_VALUE.ifSucceededBind(STRING_VALUE, mockBinder), sameInstance(SUCCESS_WITH_VALUE)); }
@Test public void otherTypeToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; OtherType otherType = new OtherType(bytes); ByteBuffer convert = this.conversionService.convert(otherType, ByteBuffer.class); assertThat(convert.array(), not(sameInstance(bytes))); assertThat(convert.array(), equalTo(bytes)); }
@Test public void shouldAllowForChainedCallsToBindFrom() { assertThat(SUCCESS_WITH_VALUE.ifSucceededBindFrom(mockSupplier, mockBinder), sameInstance(SUCCESS_WITH_VALUE)); }
@Test public void getSessionMutexExplicit() { Object mutex = new Object(); this.simpAttributes.setAttribute(SimpAttributes.SESSION_MUTEX_NAME, mutex); assertThat(this.simpAttributes.getSessionMutex(), sameInstance(mutex)); }
@Test @SuppressWarnings("unchecked") public void shouldReturnFailureForMergeOfFailed() { assertThat(FAILURE_WITH_THROWABLE.ifSucceededMerge(STRING_VALUE, mockMerger), sameInstance((Result) FAILURE_WITH_THROWABLE)); verifyZeroInteractions(mockValueFunction); }
@Test public void createDateTimeFormatterWithFallback() { DateTimeFormatter fallback = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG); DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback); assertThat(formatter, is(sameInstance(fallback))); }
@Test @SuppressWarnings("unchecked") public void shouldReturnFailureForMergeFromOfFailed() { assertThat(FAILURE_WITH_THROWABLE.ifSucceededMergeFrom(mockSupplier, mockMerger), sameInstance((Result) FAILURE_WITH_THROWABLE)); verifyZeroInteractions(mockValueFunction); verifyZeroInteractions(mockSupplier); }
@Test public void registerDestructionCallback() { Runnable callback = Mockito.mock(Runnable.class); this.simpAttributes.registerDestructionCallback("name1", callback); assertThat(this.simpAttributes.getAttribute( SimpAttributes.DESTRUCTION_CALLBACK_NAME_PREFIX + "name1"), sameInstance(callback)); }
@Test public void shouldReturnFailureForFlatMapOfFailed() { assertThat(FAILURE_WITH_THROWABLE.ifSucceededAttemptMap(mockSucceededValueFunction), sameInstance(FAILURE_WITH_THROWABLE)); verifyZeroInteractions(mockSucceededValueFunction); }