List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:com.pinterest.secor.common.FileRegistryTest.java
public void testGetOrCreateWriterCompressed() throws Exception { createCompressedWriter();/*from www . j av a 2 s. com*/ mRegistry.getOrCreateWriter(mLogFilePathGz, new GzipCodec()); // Verify that the method has been called exactly once (the default). PowerMockito.verifyStatic(); FileUtil.delete(PATH_GZ); PowerMockito.verifyStatic(); FileUtil.delete(CRC_PATH); PowerMockito.verifyStatic(); ReflectionUtil.createFileWriter(Mockito.any(String.class), Mockito.any(LogFilePath.class), Mockito.any(CompressionCodec.class)); TopicPartition topicPartition = new TopicPartition("some_topic", 0); Collection<TopicPartition> topicPartitions = mRegistry.getTopicPartitions(); assertEquals(1, topicPartitions.size()); assertTrue(topicPartitions.contains(topicPartition)); Collection<LogFilePath> logFilePaths = mRegistry.getPaths(topicPartition); assertEquals(1, logFilePaths.size()); assertTrue(logFilePaths.contains(mLogFilePath)); }
From source file:com.pinterest.secor.common.FileRegistryTest.java
public void testGetOrCreateWriter() throws Exception { createWriter();//w w w .j a v a2 s . co m // Call the method again. This time it should return an existing writer. mRegistry.getOrCreateWriter(mLogFilePath, null); // Verify that the method has been called exactly once (the default). PowerMockito.verifyStatic(); ReflectionUtil.createFileWriter(Mockito.any(String.class), Mockito.any(LogFilePath.class), Mockito.any(CompressionCodec.class)); PowerMockito.verifyStatic(); FileUtil.delete(PATH); PowerMockito.verifyStatic(); FileUtil.delete(CRC_PATH); TopicPartition topicPartition = new TopicPartition("some_topic", 0); Collection<TopicPartition> topicPartitions = mRegistry.getTopicPartitions(); assertEquals(1, topicPartitions.size()); assertTrue(topicPartitions.contains(topicPartition)); Collection<LogFilePath> logFilePaths = mRegistry.getPaths(topicPartition); assertEquals(1, logFilePaths.size()); assertTrue(logFilePaths.contains(mLogFilePath)); }
From source file:com.precioustech.fxtrading.instrument.InstrumentServiceTest.java
@Test public void testAll() { @SuppressWarnings("unchecked") InstrumentDataProvider<String> instrumentDataProvider = mock(InstrumentDataProvider.class); Collection<TradeableInstrument<String>> instruments = createInstruments(); when(instrumentDataProvider.getInstruments()).thenReturn(instruments); InstrumentService<String> service = new InstrumentService<String>(instrumentDataProvider); Collection<TradeableInstrument<String>> usdpairs = service.getAllPairsWithCurrency("USD"); assertEquals(4, usdpairs.size());/*from w w w. ja v a 2 s .co m*/ TradeableInstrument<String> usdjpy = new TradeableInstrument<String>("USD_JPY"); assertTrue(usdpairs.contains(usdjpy)); Collection<TradeableInstrument<String>> jpypairs = service.getAllPairsWithCurrency("JPY"); assertEquals(2, jpypairs.size()); jpypairs.contains(usdjpy); Collection<TradeableInstrument<String>> xaupairs = service.getAllPairsWithCurrency("XAU"); assertTrue(xaupairs.isEmpty()); Collection<TradeableInstrument<String>> nullpairs = service.getAllPairsWithCurrency(null); assertTrue(nullpairs.isEmpty()); assertEquals(nonjpypip, service.getPipForInstrument(new TradeableInstrument<String>("GBP_CHF")), TradingTestConstants.precision); assertEquals(jpypip, service.getPipForInstrument(usdjpy), TradingTestConstants.precision); assertEquals(1.0, service.getPipForInstrument(new TradeableInstrument<String>("XAU_EUR")), TradingTestConstants.precision); }
From source file:edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal.PscFelixPersistenceManagerTest.java
private void assertDictionaryKeys(Dictionary<String, ?> actual, String... expectedKeys) { Collection<String> actualKeys = EnumerationUtils.toList(actual.keys()); for (String expectedKey : expectedKeys) { assertTrue("Missing key " + expectedKey, actualKeys.contains(expectedKey)); }/*from www.j a v a2 s .c o m*/ assertEquals("Wrong number of keys", expectedKeys.length, actualKeys.size()); }
From source file:grails.plugin.searchable.internal.compass.DefaultSearchableMethodFactory.java
private Map getDefaultOptions(String methodName) { if (defaultMethodOptions.containsKey(methodName)) { return (Map) defaultMethodOptions.get(methodName); }// w w w . j a v a 2s. c om final Collection searchMethodsNames = Arrays.asList("search", "searchTop", "searchEvery", "moreLikeThis", "countHits"); if (searchMethodsNames.contains(methodName)) { return (Map) defaultMethodOptions.get("search"); } return null; }
From source file:com.threewks.thundr.module.Modules.java
private boolean allModulesStarted() { Collection<ModuleStatus> values = status.values(); return !values.contains(ModuleStatus.Added) && !values.contains(ModuleStatus.DependenciesResolved) && !values.contains(ModuleStatus.Initialised) && !values.contains(ModuleStatus.Configured); }
From source file:sawtooth.examples.jvmsc.JvmScHandler.java
/** * the method that stores bytecode in the state. */// w w w.ja v a 2 s. co m public void store(ByteString bytecode, ArrayList<String> methods, State state) throws InvalidTransactionException, InternalError { // Calculate Address for bytecode String namespace = Utils.hash512(this.transactionFamilyName().getBytes()).substring(0, 6); String addr = namespace + Utils.hash512(bytecode.toByteArray()); // Need to set {addr: {Bytecode: bytecode, Methods: Methods}} JVMEntry data = JVMEntry.newBuilder().setBytecode(bytecode).addAllMethods(methods).build(); Map.Entry<String, ByteString> entry = new AbstractMap.SimpleEntry<String, ByteString>(addr, data.toByteString()); Collection<Map.Entry<String, ByteString>> entries = new ArrayList<Map.Entry<String, ByteString>>(); entries.add(entry); Collection<String> response = state.set(entries); if (!response.contains(addr)) { throw new InvalidTransactionException("Bytecode was not stored succefully"); } }
From source file:com.bigdata.dastor.service.StorageProxy.java
private static void assureSufficientLiveNodes(int blockFor, Collection<InetAddress> writeEndpoints, Multimap<InetAddress, InetAddress> hintedEndpoints, ConsistencyLevel consistencyLevel) throws UnavailableException { if (consistencyLevel == ConsistencyLevel.ANY) { // ensure there are blockFor distinct living nodes (hints are ok). if (hintedEndpoints.keySet().size() < blockFor) throw new UnavailableException(); }/*ww w . j a v a 2s.c o m*/ // count destinations that are part of the desired target set int liveNodes = 0; for (InetAddress destination : hintedEndpoints.keySet()) { if (writeEndpoints.contains(destination)) liveNodes++; } if (liveNodes < blockFor) { throw new UnavailableException(); } }
From source file:com.cedac.security.oauth2.provider.token.store.TokenStoreBaseTests.java
@Test public void testRemovedTokenCannotBeFoundByUsername() { OAuth2AccessToken token = new DefaultOAuth2AccessToken("testToken"); OAuth2Authentication expectedAuthentication = new OAuth2Authentication( RequestTokenFactory.createOAuth2Request("id", false), new TestAuthentication("test2", false)); getTokenStore().storeAccessToken(token, expectedAuthentication); getTokenStore().removeAccessToken(token); Collection<OAuth2AccessToken> tokens = getTokenStore().findTokensByClientIdAndUserName("id", "test2"); assertFalse(tokens.contains(token)); assertTrue(tokens.isEmpty());//w w w . j a v a2s . c o m }
From source file:car_counter.storage.sqlite.SqliteStorage.java
private void initialiseTables() throws SQLException { Collection<String> tables = new ArrayList<String>(); ResultSet resultSet = connection.getMetaData().getTables(null, null, "%", null); while (resultSet.next()) { tables.add(resultSet.getString(3)); }//from w w w.java 2 s .co m if (tables.contains("detected_vehicles")) { return; } Statement statement = connection.createStatement(); statement.executeUpdate("create table detected_vehicles (" + "id integer primary key," + "timestamp integer," + "initial_location integer," + "end_location integer," + "speed float," + "colour string," + "video_file string)"); }