List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:com.espertech.esper.epl.join.table.PropertyIndexedEventTableSingleUnique.java
@Override public Set<EventBean> lookup(Object key) { EventBean event = propertyIndex.get(key); if (event != null) { return Collections.singleton(event); }/*from w w w . j a v a 2 s .c o m*/ return null; }
From source file:org.synyx.hades.extensions.converter.GenericDaoConverter.java
public Set<ConvertiblePair> getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(Object.class, Object.class)); }
From source file:com.netflix.spinnaker.clouddriver.artifacts.gcs.GcsArtifactCredentials.java
public GcsArtifactCredentials(String applicationName, GcsArtifactAccount account) throws IOException, GeneralSecurityException { HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); String credentialsPath = account.getJsonPath(); GoogleCredential credential;// w w w. j a v a 2s .c o m if (!StringUtils.isEmpty(credentialsPath)) { FileInputStream stream = new FileInputStream(credentialsPath); credential = GoogleCredential.fromStream(stream, transport, jsonFactory) .createScoped(Collections.singleton(StorageScopes.DEVSTORAGE_READ_ONLY)); log.info("Loaded credentials from {}", credentialsPath); } else { log.info( "artifacts.gcs.enabled without artifacts.gcs.[].jsonPath. Using default application credentials."); credential = GoogleCredential.getApplicationDefault(); } name = account.getName(); storage = new Storage.Builder(transport, jsonFactory, credential).setApplicationName(applicationName) .build(); }
From source file:ch.cyberduck.core.irods.IRODSUploadFeatureTest.java
@Test @Ignore//from www. j a v a 2s . c om public void testAppend() throws Exception { final ProtocolFactory factory = new ProtocolFactory( new HashSet<>(Collections.singleton(new IRODSProtocol()))); final Profile profile = new ProfilePlistReader(factory) .read(new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile")); final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials(System.getProperties().getProperty("irods.key"), System.getProperties().getProperty("irods.secret"))); final IRODSSession session = new IRODSSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final int length = 32770; final byte[] content = RandomUtils.nextBytes(length); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out); out.close(); final Checksum checksumPart1; final Checksum checksumPart2; final Path test = new Path(new IRODSHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().length(content.length / 2); checksumPart1 = new IRODSUploadFeature(session).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } { final TransferStatus status = new TransferStatus().length(content.length / 2).skip(content.length / 2) .append(true); checksumPart2 = new IRODSUploadFeature(session).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } assertNotEquals(checksumPart1, checksumPart2); final byte[] buffer = new byte[content.length]; final InputStream in = new IRODSReadFeature(session).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); assertArrayEquals(content, buffer); new IRODSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); local.delete(); session.close(); }
From source file:eu.openanalytics.rsb.data.FileCatalogManager.java
@PostConstruct public void createCatalogTree() throws IOException { final Set<String> applicationNames = getConfiguration().isApplicationAwareCatalog() ? collectionAllApplicationNames() : Collections.singleton("ignored"); for (final String applicationName : applicationNames) { for (final CatalogSection catalogSection : CatalogSection.values()) { FileUtils.forceMkdir(getCatalogSectionDirectory(catalogSection, applicationName)); }/*from ww w . j av a 2 s . c om*/ } }
From source file:org.openlmis.fulfillment.service.referencedata.OrderableReferenceDataServiceTest.java
@Test public void shouldReturnOrderablesById() { OrderableDto product = mockPageResponseEntityAndGetDto(); UUID orderableId = UUID.randomUUID(); List<OrderableDto> response = service.findByIds(Collections.singleton(orderableId)); assertThat(response, hasSize(1));// w ww . java 2 s. c o m assertThat(response, hasItem(product)); verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), refEq(new DynamicPageTypeReference<>(OrderableDto.class))); URI uri = uriCaptor.getValue(); assertEquals(serviceUrl + service.getUrl() + "?id=" + orderableId.toString(), uri.toString()); assertAuthHeader(entityCaptor.getValue()); assertNull(entityCaptor.getValue().getBody()); }
From source file:fll.db.NonNumericNominees.java
/** * Add a nominee to the database. If they already are a nominee, this function * does nothing./*from www . jav a 2 s. c o m*/ * * @throws SQLException */ public static void addNominee(final Connection connection, final int tournamentId, final String category, final int teamNumber) throws SQLException { addNominees(connection, tournamentId, category, Collections.singleton(teamNumber)); }
From source file:de.hybris.platform.b2b.services.impl.DefaultB2BApproverServiceMockTest.java
@Test public void testGetAllApprovers() throws Exception { final B2BCustomerModel mockB2BCustomerModel = Mockito.mock(B2BCustomerModel.class); final B2BUnitModel mockB2BUnitModel = Mockito.mock(B2BUnitModel.class); final B2BUserGroupModel mockB2BUserGroupModel = Mockito.mock(B2BUserGroupModel.class); final PrincipalGroupModel mockPrincipalGroupModel = Mockito.mock(PrincipalGroupModel.class); when(mockB2BCustomerModel.getCustomerID()).thenReturn("customer123"); when(mockB2BUserGroupModel.getUid()).thenReturn(B2BConstants.B2BAPPROVERGROUP); when(mockB2BCustomerModel.getGroups()).thenReturn(Collections.singleton(mockPrincipalGroupModel)); when(b2bUnitService.getParent(mockB2BCustomerModel)).thenReturn(mockB2BUnitModel); when(mockB2BCustomerModel.getApprovers()).thenReturn(Collections.singleton(mockB2BCustomerModel)); when(mockB2BCustomerModel.getApproverGroups()).thenReturn(Collections.singleton(mockB2BUserGroupModel)); when(userService.getUserGroupForUID(B2BConstants.B2BAPPROVERGROUP)).thenReturn(mockB2BUserGroupModel); when(Boolean.valueOf(userService.isMemberOfGroup(mockB2BCustomerModel, mockB2BUserGroupModel))) .thenReturn(Boolean.TRUE); //Only return active approvers when(mockB2BCustomerModel.getActive()).thenReturn(Boolean.TRUE); final List<B2BCustomerModel> allApprovers = defaultB2BApproverService.getAllApprovers(mockB2BCustomerModel); Assert.assertNotNull(allApprovers);//from www. j a v a2s .co m Assert.assertTrue(CollectionUtils.isNotEmpty(allApprovers)); Assert.assertEquals(allApprovers.get(0).getCustomerID(), mockB2BCustomerModel.getCustomerID()); }
From source file:io.logspace.agent.hq.HqClient.java
public HqClient(String baseUrl, String agentControllerId, String spaceToken) { super();//from w w w . j av a 2 s . c om this.baseUrl = baseUrl; if (this.baseUrl == null || this.baseUrl.trim().length() == 0) { throw new AgentControllerInitializationException("The base URL must not be empty!"); } this.agentControllerId = agentControllerId; this.spaceToken = spaceToken; RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(TIMEOUT) .setConnectTimeout(TIMEOUT).setSocketTimeout(TIMEOUT).build(); Set<? extends Header> defaultHeaders = Collections .singleton(new BasicHeader("Accept", APPLICATION_JSON.getMimeType())); this.httpClient = HttpClients.custom().disableAutomaticRetries().setDefaultRequestConfig(requestConfig) .setDefaultHeaders(defaultHeaders).build(); }
From source file:com.vrem.wifianalyzer.wifi.predicate.FilterPredicateTest.java
@Before public void setUp() { when(settings.getWiFiBand()).thenReturn(WiFiBand.GHZ5); when(settings.getSSIDs()).thenReturn(new HashSet<>(Arrays.asList(SSID, SSID))); when(settings.getWiFiBands()).thenReturn(Collections.singleton(WiFiBand.GHZ2)); when(settings.getStrengths()).thenReturn(new HashSet<>(Arrays.asList(Strength.TWO, Strength.FOUR))); when(settings.getSecurities()).thenReturn(new HashSet<>(Arrays.asList(Security.WEP, Security.WPA2))); }