List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:am.ik.categolj2.domain.service.user.UserServiceImplTest.java
@Test(expected = BusinessException.class) @Transactional//from w ww . j av a 2 s . c om public void testCreate_email_is_used() { User user = new User("testuser2", null, "admin@example.com", true, false, "Test", "User", null); user.setRoles(Collections.singleton(new Role(2))); userService.create(user, "password"); }
From source file:io.pravega.controller.eventProcessor.impl.EventProcessorGroupImpl.java
void initialize() throws CheckpointStoreException { checkpointStore.addReaderGroup(actorSystem.getProcess(), eventProcessorConfig.getConfig().getReaderGroupName()); // Continue creating reader group if adding reader group to checkpoint store succeeds. readerGroup = createIfNotExists(actorSystem.readerGroupManager, eventProcessorConfig.getConfig().getReaderGroupName(), ReaderGroupConfig.builder().startingPosition(Sequence.MIN_VALUE).build(), Collections.singleton(eventProcessorConfig.getConfig().getStreamName())); createEventProcessors(eventProcessorConfig.getConfig().getEventProcessorCount()); }
From source file:mitm.application.djigzo.james.CertificatesTest.java
@Test public void testSerialize() throws Exception { X509Certificate certificate = TestUtils .loadCertificate(new File("test/resources/testdata/certificates/testcertificate.cer")); Certificates certificates = new Certificates(Collections.singleton(certificate)); assertEquals(1, certificates.getCertificates().size()); byte[] serialized = SerializationUtils.serialize(certificates); Certificates deserialized = (Certificates) SerializationUtils.deserialize(serialized); assertEquals(certificates.getCertificates(), deserialized.getCertificates()); }
From source file:com.devicehive.handler.notification.NotificationSubscribeRequestHandler.java
private Collection<DeviceNotification> findNotifications(String device, Collection<String> names, Date timestamp) {/*from w ww . j a va 2 s . c o m*/ Collection<DeviceNotification> notifications = Collections.emptyList(); if (timestamp != null) { notifications = hazelcastService.find(null, names, Collections.singleton(device), LIMIT, timestamp, null, null, DeviceNotification.class); } return notifications; }
From source file:org.surfnet.oaaas.resource.ClientResourceTest.java
@Test public void scopesShouldBeSubsetOfResourceServerScopes() { Client client = new Client(); request.setAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE, new VerifyTokenResponse("", new ArrayList<String>(), new AuthenticatedPrincipal("user"), 0L)); client.setScopes(Arrays.asList("Some", "arbitrary", "set")); client.setName("clientname"); ResourceServer resourceServer = new ResourceServer(); resourceServer.setScopes(Arrays.asList("read", "update", "delete")); when(resourceServerRepository.findByIdAndOwner(1L, "user")).thenReturn(resourceServer); final ConstraintViolation<Client> violation = (ConstraintViolation<Client>) mock(ConstraintViolation.class); Set<ConstraintViolation<Client>> violations = Collections.singleton(violation); when(validator.validate(client)).thenReturn(violations); final Response response = clientResource.put(request, 1L, client); assertEquals(400, response.getStatus()); assertEquals("invalid_scope", ((ErrorResponse) response.getEntity()).getError()); }
From source file:io.pivotal.cla.data.repository.IndividualSignatureRepositoryTests.java
@Test public void findSignatureNotUser() { user.setGitHubLogin("notfound" + user.getGitHubLogin()); user.setEmails(Collections.singleton("notfound@example.com")); assertThat(claService.findIndividualSignaturesFor(user, cla.getName())).isNull(); ;//from w ww . j av a2s. c o m }
From source file:com.github.thorbenlindhauer.cluster.ep.TruncatedGaussianPotentialResolver.java
@Override public FactorSet<GaussianFactor> project(FactorSet<GaussianFactor> additionalFactors, Scope projectionScope) { if (projectionScope.size() != 1 || !projectionScope.contains(predictionVariable.getId())) { throw new InferenceException("Can only project on variable " + predictionVariable.getId() + " not on scope " + projectionScope); }/*from w w w. java2 s . co m*/ for (GaussianFactor factor : additionalFactors.getFactors()) { Scope factorScope = factor.getVariables(); if (factorScope.size() != 1 || !factorScope.contains(predictionVariable.getId())) { throw new InferenceException( "Can only project univariate gaussians over variable " + predictionVariable.getId()); } } GaussianFactor jointFactor = FactorUtil.jointDistribution(additionalFactors.getFactors()); double jointVariance = jointFactor.getCovarianceMatrix().getEntry(0, 0); double jointStandardDeviation = Math.sqrt(jointVariance); double jointMean = jointFactor.getMeanVector().getEntry(0); double adjustedLowerBound = lowerBound / jointStandardDeviation; double adjustedUpperBound = upperBound / jointStandardDeviation; double adjustedMean = jointMean / jointStandardDeviation; double vValue = vValue(adjustedMean, adjustedLowerBound, adjustedUpperBound); double wValue = wValue(vValue, adjustedMean, adjustedLowerBound, adjustedUpperBound); double truncatedMean = jointMean + (jointStandardDeviation * vValue); double truncatedVariance = jointVariance * (1 - wValue); GaussianFactor approximationFactor = CanonicalGaussianFactor.fromMomentForm(projectionScope, new ArrayRealVector(new double[] { truncatedMean }), new Array2DRowRealMatrix(new double[] { truncatedVariance })); return new FactorSet<GaussianFactor>(Collections.singleton(approximationFactor)); }
From source file:edu.northwestern.bioinformatics.studycalendar.web.AssignSubjectCommandTest.java
@Override protected void setUp() throws Exception { super.setUp(); subjectService = registerMockFor(SubjectService.class); subjectDao = registerDaoMockFor(SubjectDao.class); subject = createSubject("11", "Fred", "Jones", BIRTH_DATE, Gender.MALE); studySegment = setId(17, edu.northwestern.bioinformatics.studycalendar.core.Fixtures .createNamedInstance("Worcestershire", StudySegment.class)); Study study = createNamedInstance("Study A", Study.class); Site site = createNamedInstance("Northwestern", Site.class); studySite = setId(14, createStudySite(study, site)); populations = Collections.singleton(new Population()); command = new AssignSubjectCommand(); command.setSubjectService(subjectService); command.setSubjectDao(subjectDao);/*from w w w . j av a2 s.c o m*/ command.setFirstName(subject.getFirstName()); command.setLastName(subject.getLastName()); command.setPersonId(subject.getPersonId()); command.setGender(subject.getGender().getCode()); command.setDateOfBirth(BIRTH_DATE_S); command.setRadioButton(NEW); command.setIdentifier(subject.getPersonId()); command.setStartDate(START_DATE_S); command.setStudySubjectId(STUDY_SUBJECT_ID); command.setStudy(study); command.setSite(site); command.setStudySegment(studySegment); command.setPopulations(populations); assignment = new StudySubjectAssignment(); assignment.setSubject(subject); }
From source file:org.openmrs.module.emrapi.concept.EmrConceptServiceComponentTest.java
@Test public void testConceptSearchByName() throws Exception { Map<String, Concept> concepts = setupConcepts(); ConceptClass diagnosis = conceptService.getConceptClassByName("Diagnosis"); List<ConceptSearchResult> searchResults = emrConceptService.conceptSearch("malaria", Locale.ENGLISH, Collections.singleton(diagnosis), null, null, null); assertThat(searchResults.size(), is(2)); ConceptSearchResult firstResult = searchResults.get(0); ConceptSearchResult otherResult = searchResults.get(1); assertThat(firstResult.getConcept(), is(concepts.get("malaria"))); assertThat(firstResult.getConceptName().getName(), is("Malaria")); assertThat(otherResult.getConcept(), is(concepts.get("cerebral malaria"))); assertThat(otherResult.getConceptName().getName(), is("Cerebral Malaria")); }
From source file:com.opengamma.financial.analytics.UnitPositionTradeScalingFunction.java
@Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target, final Map<ValueSpecification, ValueRequirement> inputs) { // Result properties are anything that was common to the input specifications ValueProperties common = null;/*www . j a v a 2s . co m*/ for (ValueSpecification input : inputs.keySet()) { common = SumUtils.addProperties(common, input.getProperties()); } if (common == null) { // Can't have been any inputs ... ? return null; } common = common.copy().withoutAny(ValuePropertyNames.FUNCTION) .with(ValuePropertyNames.FUNCTION, getUniqueId()).get(); return Collections.singleton(new ValueSpecification(_requirementName, target.toSpecification(), common)); }