/** * A shortcut to the frequently used <code>not(equalTo(x))</code>. * <p/> * For example: * <pre>assertThat(cheese, is(not(smelly)))</pre> * instead of: * <pre>assertThat(cheese, is(not(equalTo(smelly))))</pre> * * @param value * the value that any examined object should <b>not</b> equal */ @Factory public static <T> Matcher<T> not(T value) { return not(equalTo(value)); } }
@Test public void test() { assertThat(foo, equalTo("normal")); assertThat(customFoo, equalTo("custom")); }
@Test public void testPrimitiveClasses() throws ClassNotFoundException { StatefulSerializer<Serializable> s = new CompactJavaSerializer<>(null); s.init(new TransientStateRepository()); Class<?>[] out = (Class<?>[]) s.read(s.serialize(PRIMITIVE_CLASSES)); Assert.assertThat(out, IsNot.not(IsSame.sameInstance(PRIMITIVE_CLASSES))); Assert.assertThat(out, IsEqual.equalTo(PRIMITIVE_CLASSES)); }
@Test public void shouldInferCorrectModes() { assertThat( fromRecordState( true, true ), equalTo( Command.Mode.CREATE ) ); assertThat( fromRecordState( false, true ), equalTo( Command.Mode.UPDATE ) ); assertThat( fromRecordState( false, false ), equalTo( Command.Mode.DELETE ) ); assertThat( fromRecordState( true, false ), equalTo( Command.Mode.DELETE ) ); }
@Test public void testSetPreallocSize() { long customPreallocSize = 10101; FileTxnLog.setPreallocSize(customPreallocSize); Assert.assertThat(FilePadding.getPreAllocSize(), is(equalTo(customPreallocSize))); }
@Test public void testToPinyin_char() throws BadHanyuPinyinOutputFormatCombination { char[] allChars = allChars(); final int allCharsLength = allChars.length; HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); format.setCaseType(HanyuPinyinCaseType.UPPERCASE); format.setVCharType(HanyuPinyinVCharType.WITH_V); int chineseCount = 0; for (int i = 0; i < allCharsLength; i++) { char targetChar = allChars[i]; String[] pinyins = PinyinHelper.toHanyuPinyinStringArray(targetChar, format); if (pinyins != null && pinyins.length > 0) { // is chinese chineseCount++; assertThat(Pinyin.toPinyin(targetChar), equalTo(pinyins[0])); } else { // not chinese assertThat(Pinyin.toPinyin(targetChar), equalTo(String.valueOf(targetChar))); } } //CHECKSTYLE:OFF int expectedChineseCount = 20378; //CHECKSTYLE:ON assertThat(chineseCount, is(expectedChineseCount)); }
@Test public void liftedFragmentLightCycleAreEqualsWhenTheSourceIsTheSame() { final DefaultFragmentLightCycle<Fragment> lightCycle = new DefaultFragmentLightCycle<>(); final FragmentLightCycle<Fragment> lift1 = LightCycles.lift(lightCycle); final FragmentLightCycle<Fragment> lift2 = LightCycles.lift(lightCycle); assertThat(lift1, not(sameInstance(lift2))); assertThat(lift1, equalTo(lift2)); }
private void confirmBalance( String address, String contractAddress, BigInteger expected) throws Exception { Function function = balanceOf(address); String responseValue = callSmartContractFunction(function, contractAddress); List<Type> response = FunctionReturnDecoder.decode( responseValue, function.getOutputParameters()); assertThat(response.size(), is(1)); assertThat(response.get(0), equalTo(new Uint256(expected))); }
private void assertCanCreateAndFind( GraphDatabaseService db, Label label, String propertyKey, Object value ) { Node created = createNode( db, map( propertyKey, value ), label ); try ( Transaction tx = db.beginTx() ) { Node found = db.findNode( label, propertyKey, value ); assertThat( found, equalTo( created ) ); found.delete(); tx.success(); } }
private void assertNotEquals( ValueTuple a, ValueTuple b ) { assertThat( a, not( equalTo( b ) ) ); assertThat( b, not( equalTo( a ) ) ); } }
@Test public void equalsOnlyReturnsTrueForEquivalentObjects() { // Arrange: final GroupElement g1 = MathUtils.getRandomGroupElement(); final GroupElement g2 = MathUtils.toRepresentation(g1, GroupElement.Representation.P2); final GroupElement g3 = MathUtils.toRepresentation(g1, GroupElement.Representation.CACHED); final GroupElement g4 = MathUtils.toRepresentation(g1, GroupElement.Representation.P1P1); final GroupElement g5 = MathUtils.getRandomGroupElement(); // Assert Assert.assertThat(g2, IsEqual.equalTo(g1)); Assert.assertThat(g3, IsEqual.equalTo(g1)); Assert.assertThat(g1, IsEqual.equalTo(g4)); Assert.assertThat(g1, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g2, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g3, IsNot.not(IsEqual.equalTo(g5))); Assert.assertThat(g5, IsNot.not(IsEqual.equalTo(g4))); }
@Test public void testFormatInetAddrGoodHostname() { InetSocketAddress isa = new InetSocketAddress("localhost", 1234); Assert.assertThat(NetUtils.formatInetAddr(isa), AnyOf.anyOf(IsEqual.equalTo(v4local), IsEqual.equalTo(v6local) )); }
@Test public void testDefaultOrder() throws Exception { assertThat(prefs.getDefaultOrder(), equalTo(HabitList.Order.BY_POSITION)); prefs.setDefaultOrder(HabitList.Order.BY_SCORE); assertThat(prefs.getDefaultOrder(), equalTo(HabitList.Order.BY_SCORE)); storage.putString("pref_default_order", "BOGUS"); assertThat(prefs.getDefaultOrder(), equalTo(HabitList.Order.BY_POSITION)); assertThat(storage.getString("pref_default_order", ""), equalTo("BY_POSITION")); }
@Test public void shouldGrowWhenThresholdExceeded() { final float loadFactor = 0.5f; final int initialCapacity = 32; final Int2ObjectHashMap<String> map = newMap(loadFactor, initialCapacity); for (int i = 0; i < 16; i++) { map.put(i, Integer.toString(i)); } assertThat(map.resizeThreshold(), is(16)); assertThat(map.capacity(), is(initialCapacity)); assertThat(map.size(), is(16)); map.put(16, "16"); assertThat(map.resizeThreshold(), is(initialCapacity)); assertThat(map.capacity(), is(64)); assertThat(map.size(), is(17)); assertThat(map.get(16), equalTo("16")); assertThat((double)loadFactor, closeTo(map.loadFactor(), 0.0f)); }
@Test public void parseTemplateFromLocationWithKnownMediaType() throws Exception { parseTemplateProcessor.setLocation(LOCATION); parseTemplateProcessor.initialise(); String expectedExpression = IOUtils.getResourceAsString(LOCATION, this.getClass()); when(mockExpressionManager.parseLogTemplate(eq(expectedExpression), eq(event), any(), any())).thenReturn("Parsed"); CoreEvent response = parseTemplateProcessor.process(event); assertThat(response.getMessage().getPayload().getDataType().getMediaType(), is(equalTo(LOCATION_MEDIA_TYPE))); }
@Test public void liftedActivityLightCycleAreEqualsWhenTheSourceIsTheSame() { final DefaultActivityLightCycle<Activity> lightCycle = new DefaultActivityLightCycle<>(); final ActivityLightCycle<Activity> lift1 = LightCycles.lift(lightCycle); final ActivityLightCycle<Activity> lift2 = LightCycles.lift(lightCycle); assertThat(lift1, not(sameInstance(lift2))); assertThat(lift1, equalTo(lift2)); }