@Test public void plainArray() { Object k1 = generateKey(new Object[] { new String[]{"a", "b"} }); Object k2 = generateKey(new Object[] { new String[]{"a", "b"} }); Object k3 = generateKey(new Object[] { new String[]{"b", "a"} }); assertThat(k1.hashCode(), equalTo(k2.hashCode())); assertThat(k1.hashCode(), not(equalTo(k3.hashCode()))); assertThat(k1, equalTo(k2)); assertThat(k1, not(equalTo(k3))); }
private void assertNotEquals( ValueTuple a, ValueTuple b ) { assertThat( a, not( equalTo( b ) ) ); assertThat( b, not( equalTo( a ) ) ); } }
@Test public void simpleBeanPropertyErrorMessage() { PropertyMatches matches = PropertyMatches.forProperty("naem", SampleBeanProperties.class); String msg = matches.buildErrorMessage(); assertThat(msg, containsString("naem")); assertThat(msg, containsString("name")); assertThat(msg, containsString("setter")); assertThat(msg, not(containsString("field"))); }
@Test public void addShouldRetainValues() { IndexEntryUpdate<?> single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); IndexEntryUpdate<?> multi = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); assertThat( single, not( equalTo( multi ) ) ); assertThat( single.values(), equalTo( new Object[]{singleValue} ) ); assertThat( multi.values(), equalTo( multiValue ) ); }
@Test public void shouldNotFailWhenMarkedForTerminationAndPullAll() throws Exception { BoltStateMachineV1SPI spi = mock( BoltStateMachineV1SPI.class, RETURNS_MOCKS ); BoltStateMachine machine = init( newMachine( spi ) ); machine.process( new RunMessage( "RETURN 42", EMPTY_PARAMS ), nullResponseHandler() ); // move to streaming state txStateMachine( machine ).ctx.currentResult = BoltResult.EMPTY; BoltResponseHandler responseHandler = mock( BoltResponseHandler.class ); machine.markForTermination(); machine.process( PullAllMessage.INSTANCE, responseHandler ); verify( spi, never() ).reportError( any() ); assertThat( machine, not( inState( FailedState.class ) ) ); }
@Test public void patchForObject() throws URISyntaxException { // JDK client does not support the PATCH method Assume.assumeThat(this.clientHttpRequestFactory, Matchers.not(Matchers.instanceOf(SimpleClientHttpRequestFactory.class))); String s = template.patchForObject(baseUrl + "/{method}", helloWorld, String.class, "patch"); assertEquals("Invalid content", helloWorld, s); }
@Test public void hash() { assertThat(eternal.hashCode(), is(not(temporal.hashCode()))); } }
@Test(dataProvider = "populated") public void add_whenPopulated(Queue<Integer> queue) { assertThat(queue.add(-1), is(true)); assertThat(queue.peek(), is(not(-1))); assertThat(Iterables.getLast(queue), is(-1)); assertThat(queue, hasSize(POPULATED_SIZE + 1)); assertThat(queue.size(), is(equalTo(Iterables.size(queue)))); }
@Test public void singleNullValue() { Object k1 = generateKey(new Object[] { null }); Object k2 = generateKey(new Object[] { null }); Object k3 = generateKey(new Object[] { "different" }); assertThat(k1.hashCode(), equalTo(k2.hashCode())); assertThat(k1.hashCode(), not(equalTo(k3.hashCode()))); assertThat(k1, equalTo(k2)); assertThat(k1, not(equalTo(k3))); assertThat(k1, instanceOf(SimpleKey.class)); }
@Test public void simpleFieldPropertyErrorMessage() { PropertyMatches matches = PropertyMatches.forField("naem", SampleFieldProperties.class); String msg = matches.buildErrorMessage(); assertThat(msg, containsString("naem")); assertThat(msg, containsString("name")); assertThat(msg, containsString("field")); assertThat(msg, not(containsString("setter"))); }
@Test public void removeShouldRetainValues() { IndexEntryUpdate<?> single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); IndexEntryUpdate<?> multi = IndexEntryUpdate .remove( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); assertThat( single, not( equalTo( multi ) ) ); assertThat( single.values(), equalTo( new Object[]{singleValue} ) ); assertThat( multi.values(), equalTo( multiValue ) ); }
@Test public void testRequestAttributeMatcher() throws Exception { String producibleMediaTypes = HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; this.mockMvc.perform(get("/1")) .andExpect(request().attribute(producibleMediaTypes, hasItem(MediaType.APPLICATION_JSON))) .andExpect(request().attribute(producibleMediaTypes, not(hasItem(MediaType.APPLICATION_XML)))); }
@Test public void load_fallback() throws Exception { assertThat(UnsafeAccess.load("abc", UnsafeAccess.OPEN_JDK), is(UnsafeAccess.UNSAFE)); assertThat(UnsafeAccess.load("abc", "efg"), is(not(UnsafeAccess.UNSAFE))); }
@Test public void equals_false() { EventTypeFilter<Integer, Integer> other = new EventTypeFilter<>( Mockito.mock(CacheEntryListener.class), Mockito.mock(CacheEntryEventFilter.class)); assertThat(filter, is(not(equalTo(other)))); }
@Test void streamFilesRecursiveMustNotSeeFilesLaterCreatedBaseDirectory() throws Exception { File a = existingFile( "a" ); Stream<FileHandle> stream = fsa.streamFilesRecursive( a.getParentFile() ); File b = existingFile( "b" ); Set<File> files = stream.map( FileHandle::getFile ).collect( toSet() ); assertThat( files, contains( a ) ); assertThat( files, not( contains( b ) ) ); }
@Test public void singleValue(){ Object k1 = generateKey(new Object[] { "a" }); Object k2 = generateKey(new Object[] { "a" }); Object k3 = generateKey(new Object[] { "different" }); assertThat(k1.hashCode(), equalTo(k2.hashCode())); assertThat(k1.hashCode(), not(equalTo(k3.hashCode()))); assertThat(k1, equalTo(k2)); assertThat(k1, not(equalTo(k3))); assertThat(k1, equalTo("a")); }
@Test public void test() { ClassNode cls = getClassNodeFromSmaliWithPath("arith", "TestArithNot"); String code = cls.getCode().toString(); assertThat(code, containsString("return ~a;")); assertThat(code, containsString("return ~b;")); assertThat(code, not(containsString("^"))); } }
@Test(dataProvider = "full") public void add_whenPopulated(LinkedDeque<LinkedValue> deque) { LinkedValue value = new LinkedValue(SIZE); assertThat(deque.add(value), is(true)); assertThat(deque.peekFirst(), is(not(value))); assertThat(deque.peekLast(), is(value)); assertThat(deque, hasSize(SIZE + 1)); }
@CheckNoWriter @CheckNoStats @Test(dataProvider = "caches") @CacheSpec(population = Population.EMPTY, removalListener = { Listener.DEFAULT, Listener.REJECTING }) public void equalsAndHashCodeFail_empty(Map<Integer, Integer> map, CacheContext context) { Map<Integer, Integer> other = ImmutableMap.of(1, -1, 2, -2, 3, -3); assertThat(map.equals(other), is(false)); assertThat(other.equals(map), is(false)); assertThat(map.hashCode(), is(not(equalTo(other.hashCode())))); }
@Test void profilerMustLimitItselfToProfiledRegion() throws Exception { Profiler profiler = Profiler.profiler(); try ( Profiler.ProfiledInterval ignored = profiler.profile() ) { expensiveComputation(); } otherIntenseWork(); String output = getProfilerOutput( profiler ); assertThat( output, not( containsString( "otherIntensiveWork" ) ) ); }