本文整理汇总了Java中org.testng.collections.Sets.newHashSet方法的典型用法代码示例。如果您正苦于以下问题:Java Sets.newHashSet方法的具体用法?Java Sets.newHashSet怎么用?Java Sets.newHashSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.collections.Sets
的用法示例。
在下文中一共展示了Sets.newHashSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataProviders
import org.testng.collections.Sets; //导入方法依赖的package包/类
/** A Method that returns all the Methods that are annotated with @DataProvider
* in a given package. Should be moved to htsjdk and used from there
*
* @param packageName the package under which to look for classes and methods
* @return an iterator to collection of Object[]'s consisting of {Method method, Class clazz} pair.
* where method has the @DataProviderAnnotation and is a member of clazz.
*/
public static Iterator<Object[]> getDataProviders(final String packageName) {
List<Object[]> data = new ArrayList<>();
final ClassFinder classFinder = new ClassFinder();
classFinder.find(packageName, Object.class);
for (final Class<?> testClass : classFinder.getClasses()) {
if (Modifier.isAbstract(testClass.getModifiers()) || Modifier.isInterface(testClass.getModifiers()))
continue;
Set<Method> methodSet = Sets.newHashSet();
methodSet.addAll(Arrays.asList(testClass.getDeclaredMethods()));
methodSet.addAll(Arrays.asList(testClass.getMethods()));
for (final Method method : methodSet) {
if (method.isAnnotationPresent(DataProvider.class)) {
data.add(new Object[]{method, testClass});
}
}
}
return data.iterator();
}
示例2: uniqueMethodList
import org.testng.collections.Sets; //导入方法依赖的package包/类
/**
* Extracts the unique list of <code>ITestNGMethod</code>s.
*/
public static List<ITestNGMethod> uniqueMethodList(Collection<List<ITestNGMethod>> methods) {
Set<ITestNGMethod> resultSet = Sets.newHashSet();
for (List<ITestNGMethod> l : methods) {
resultSet.addAll(l);
}
return Lists.newArrayList(resultSet);
}
示例3: extractTrades
import org.testng.collections.Sets; //导入方法依赖的package包/类
private Set<ManageableTrade> extractTrades(PositionMaster positionMaster) {
Set<ManageableTrade> tradeSet = Sets.newHashSet();
for (ManageablePosition p : positionMaster.search(new PositionSearchRequest()).getPositions()) {
tradeSet.addAll(p.getTrades());
}
return tradeSet;
}
示例4: basicTest
import org.testng.collections.Sets; //导入方法依赖的package包/类
@Test
public void basicTest() throws IOException {
final Set<String> headersOfInterest = Sets.newHashSet(Arrays.asList("name", "learning_SAMPLE_0"));
final List<SimpleAnnotatedGenomicRegion> simpleAnnotatedGenomicRegions =
SimpleAnnotatedGenomicRegion.readAnnotatedRegions(TEST_FILE, headersOfInterest);
Assert.assertEquals(simpleAnnotatedGenomicRegions.size(), 15);
Assert.assertTrue(simpleAnnotatedGenomicRegions.stream()
.mapToInt(s -> s.getAnnotations().entrySet().size())
.allMatch(i -> i == headersOfInterest.size()));
Assert.assertTrue(simpleAnnotatedGenomicRegions.stream().allMatch(s -> s.getAnnotations().keySet().containsAll(headersOfInterest)));
// Grab the first 15 and test values
List<SimpleAnnotatedGenomicRegion> gtRegions = Arrays.asList(
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 30365, 30503), ImmutableSortedMap.of("name", "target_1_None", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 69088, 70010), ImmutableSortedMap.of("name", "target_2_None", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 367656, 368599), ImmutableSortedMap.of("name", "target_3_None", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 621093, 622036), ImmutableSortedMap.of("name", "target_4_None", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 861319, 861395), ImmutableSortedMap.of("name", "target_5_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 865532, 865718), ImmutableSortedMap.of("name", "target_6_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 866416, 866471), ImmutableSortedMap.of("name", "target_7_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 871149, 871278), ImmutableSortedMap.of("name", "target_8_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 874417, 874511), ImmutableSortedMap.of("name", "target_9_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 874652, 874842), ImmutableSortedMap.of("name", "target_10_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 876521, 876688), ImmutableSortedMap.of("name", "target_11_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 877513, 877633), ImmutableSortedMap.of("name", "target_12_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 877787, 877870), ImmutableSortedMap.of("name", "target_13_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 877936, 878440), ImmutableSortedMap.of("name", "target_14_SAMD11", "learning_SAMPLE_0", "2")),
new SimpleAnnotatedGenomicRegion(new SimpleInterval("1", 878630, 878759), ImmutableSortedMap.of("name", "target_15_SAMD11", "learning_SAMPLE_0", "2"))
);
Assert.assertEquals(simpleAnnotatedGenomicRegions.subList(0, gtRegions.size()), gtRegions);
}
示例5: writeAllToBuffer
import org.testng.collections.Sets; //导入方法依赖的package包/类
private void writeAllToBuffer(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
xmlBuffer.push(XMLReporterConfig.TAG_TEST, getSuiteResultAttributes(suiteResult));
Set<ITestResult> testResults = Sets.newHashSet();
ITestContext testContext = suiteResult.getTestContext();
addAllTestResults(testResults, testContext.getPassedTests());
addAllTestResults(testResults, testContext.getFailedTests());
addAllTestResults(testResults, testContext.getSkippedTests());
addAllTestResults(testResults, testContext.getPassedConfigurations());
addAllTestResults(testResults, testContext.getSkippedConfigurations());
addAllTestResults(testResults, testContext.getFailedConfigurations());
addAllTestResults(testResults, testContext.getFailedButWithinSuccessPercentageTests());
addTestResults(xmlBuffer, testResults);
xmlBuffer.pop();
}
示例6: testSelectQueriesWithAllSelectionPolicies
import org.testng.collections.Sets; //导入方法依赖的package包/类
@Test
public void testSelectQueriesWithAllSelectionPolicies(){
QueryContext q1 = mock(QueryContext.class);
QueryContext q2 = mock(QueryContext.class);
QueryContext q3 = mock(QueryContext.class);
/* eligibleQueriesSet1, eligibleQueriesSet2, eligibleQueriesSet3 have q1 in common */
Set<QueryContext> eligibleQueriesSet1 = Sets.newHashSet(Arrays.asList(q1, q2));
Set<QueryContext> eligibleQueriesSet2 = Sets.newHashSet(Arrays.asList(q1, q3));
Set<QueryContext> eligibleQueriesSet3 = Sets.newHashSet(Arrays.asList(q1, q2));
FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
EstimatedImmutableQueryCollection mockWaitingQueries = mock(EstimatedImmutableQueryCollection.class);
WaitingQueriesSelectionPolicy policy1 = mock(WaitingQueriesSelectionPolicy.class);
WaitingQueriesSelectionPolicy policy2 = mock(WaitingQueriesSelectionPolicy.class);
WaitingQueriesSelectionPolicy driverSelectionPolicy = mock(WaitingQueriesSelectionPolicy.class);
when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(ImmutableSet.of(driverSelectionPolicy));
/* selection policy1 will return eligibleQueriesSet1 */
when(policy1.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet1);
/* selection policy2 will return eligibleQueriesSet2 */
when(policy2.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet2);
/* driver selection policy will return eligibleQueriesSet3 */
when(driverSelectionPolicy.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet3);
WaitingQueriesSelector selector = new UnioningWaitingQueriesSelector(ImmutableSet.of(policy1, policy2));
/* selector should return only eligibleQuery1, as this is the only common eligible waiting query returned
* by both selection policies */
Set<QueryContext> actualEligibleQueries = selector.selectQueries(mockFinishedQuery, mockWaitingQueries);
Set<QueryContext> expectedEligibleQueries = Sets.newHashSet(Arrays.asList(q1, q2, q3));
assertEquals(actualEligibleQueries, expectedEligibleQueries);
}
示例7: loadUserByUsername_SuperUser
import org.testng.collections.Sets; //导入方法依赖的package包/类
@Test
public void loadUserByUsername_SuperUser()
{
UserDetails user = userDetailsService.loadUserByUsername("admin");
Set<String> authorities = Sets.newHashSet(Collections2.transform(user.getAuthorities(),
(Function<GrantedAuthority, String>) GrantedAuthority::getAuthority));
assertTrue(authorities.contains(SecurityUtils.AUTHORITY_SU));
assertEquals(authorities.size(), 1);
}
示例8: loadUserByUsername_NonSuperUser
import org.testng.collections.Sets; //导入方法依赖的package包/类
@Test
public void loadUserByUsername_NonSuperUser()
{
UserDetails user = userDetailsService.loadUserByUsername("user");
Set<String> authorities = Sets.newHashSet(Collections2.transform(user.getAuthorities(),
(Function<GrantedAuthority, String>) GrantedAuthority::getAuthority));
assertEquals(authorities.size(), 0);
}
示例9: initListeners
import org.testng.collections.Sets; //导入方法依赖的package包/类
private void initListeners() {
//
// Find all the listener factories and collect all the listeners requested in a
// @Listeners annotation.
//
Set<Class<? extends ITestNGListener>> listenerClasses = Sets.newHashSet();
Class<? extends ITestNGListenerFactory> listenerFactoryClass = null;
for (IClass cls : getTestClasses()) {
Class<?> realClass = cls.getRealClass();
ListenerHolder listenerHolder = findAllListeners(realClass);
if (listenerFactoryClass == null) {
listenerFactoryClass = listenerHolder.listenerFactoryClass;
}
listenerClasses.addAll(listenerHolder.listenerClasses);
}
//
// Now we have all the listeners collected from @Listeners and at most one
// listener factory collected from a class implementing ITestNGListenerFactory.
// Instantiate all the requested listeners.
//
ITestNGListenerFactory listenerFactory = null;
// If we found a test listener factory, instantiate it.
try {
if (m_testClassFinder != null) {
IClass ic = m_testClassFinder.getIClass(listenerFactoryClass);
if (ic != null) {
listenerFactory = (ITestNGListenerFactory) ic.getInstances(false)[0];
}
}
if (listenerFactory == null) {
listenerFactory = listenerFactoryClass != null ? listenerFactoryClass.newInstance() : null;
}
}
catch(Exception ex) {
throw new TestNGException("Couldn't instantiate the ITestNGListenerFactory: "
+ ex);
}
// Instantiate all the listeners
for (Class<? extends ITestNGListener> c : listenerClasses) {
if (IClassListener.class.isAssignableFrom(c) && m_classListeners.containsKey(c)) {
continue;
}
ITestNGListener listener = listenerFactory != null ? listenerFactory.createListener(c) : null;
if (listener == null) {
listener = ClassHelper.newInstance(c);
}
addListener(listener);
}
}
示例10: testSelectQueriesWithNoSelectionPolicies
import org.testng.collections.Sets; //导入方法依赖的package包/类
@Test
public void testSelectQueriesWithNoSelectionPolicies(){
FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
EstimatedImmutableQueryCollection mockWaitingQueries = mock(EstimatedImmutableQueryCollection.class);
Set<WaitingQueriesSelectionPolicy> emptySetOfPolicies = Sets.newHashSet();
when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(ImmutableSet.copyOf(emptySetOfPolicies));
WaitingQueriesSelector selector = new UnioningWaitingQueriesSelector(ImmutableSet.copyOf(emptySetOfPolicies));
/* selector should return an empty set as no selection policy is available */
Set<QueryContext> actualEligibleQueries = selector.selectQueries(mockFinishedQuery, mockWaitingQueries);
assertTrue(actualEligibleQueries.isEmpty());
}