Example usage for java.util Collections emptySet

List of usage examples for java.util Collections emptySet

Introduction

In this page you can find the example usage for java.util Collections emptySet.

Prototype

@SuppressWarnings("unchecked")
public static final <T> Set<T> emptySet() 

Source Link

Document

Returns an empty set (immutable).

Usage

From source file:com.thinkbiganalytics.feedmgr.service.feed.datasource.DerivedDatasourceFactory.java

/**
 * Builds the list of data sources for the specified data transformation feed.
 *
 * @param feed the feed// w ww  .  j  a  v  a2  s .c o m
 * @return the list of data sources
 */
@Nonnull
private Set<Datasource.ID> ensureDataTransformationSourceDatasources(@Nonnull final FeedMetadata feed) {
    // Build the data sources from the view model
    final Set<Datasource.ID> datasources = new HashSet<>();
    final Set<String> tableNames = Optional.ofNullable(feed.getDataTransformation())
            .map(FeedDataTransformation::getTableNamesFromViewModel).orElse(Collections.emptySet());

    if (!tableNames.isEmpty()) {
        DatasourceDefinition datasourceDefinition = datasourceDefinitionProvider
                .findByProcessorType(DATA_TRANSFORMATION_DEFINITION);
        if (datasourceDefinition != null) {
            tableNames.forEach(hiveTable -> {
                String schema = StringUtils.trim(StringUtils.substringBefore(hiveTable, "."));
                String table = StringUtils.trim(StringUtils.substringAfterLast(hiveTable, "."));
                String identityString = datasourceDefinition.getIdentityString();
                Map<String, String> props = new HashMap<String, String>();
                props.put("schema", schema);
                props.put("table", table);
                identityString = propertyExpressionResolver.resolveVariables(identityString, props);
                String desc = datasourceDefinition.getDescription();
                if (desc != null) {
                    desc = propertyExpressionResolver.resolveVariables(desc, props);
                }
                String title = identityString;

                DerivedDatasource derivedDatasource = datasourceProvider.ensureDerivedDatasource(
                        datasourceDefinition.getDatasourceType(), identityString, title, desc,
                        new HashMap<String, Object>(props));
                if (derivedDatasource != null) {
                    datasources.add(derivedDatasource.getId());
                }
            });
        }
    }

    // Build the data sources from the data source ids
    final List<String> datasourceIds = Optional.ofNullable(feed.getDataTransformation())
            .map(FeedDataTransformation::getDatasourceIds).orElse(Collections.emptyList());
    datasourceIds.stream().map(datasourceProvider::resolve).forEach(datasources::add);

    return datasources;
}

From source file:eu.trentorise.smartcampus.permissionprovider.model.ClientDetailsEntity.java

@Override
public Set<String> getRegisteredRedirectUri() {
    if (redirectUri != null) {
        return Utils.delimitedStringToSet(redirectUri, ",");
    }//from   w  w w  .  j  a v  a2  s  .  com
    return Collections.emptySet();
}

From source file:com.restfb.util.InsightUtilsTest.java

@Test
public void createBaseQuery0metrics() {
    Set<String> metrics = Collections.emptySet();
    assertEquals("SELECT metric, value FROM insights WHERE object_id='31698190356' AND "
            + "period=604800 AND end_time=", createBaseQuery(Period.WEEK, TEST_PAGE_OBJECT, metrics));

    // what about all empties/nulls in the list?
    metrics = new LinkedHashSet<String>();
    metrics.add(null);/*from w w w  . j a  v a2s  .co  m*/
    metrics.add("");
    metrics.add("");
    assertEquals("SELECT metric, value FROM insights WHERE object_id='31698190356' AND "
            + "period=604800 AND end_time=", createBaseQuery(Period.WEEK, TEST_PAGE_OBJECT, metrics));
}

From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java

@Before
public void setUp() {
    Logger logger = (Logger) LoggerFactory.getLogger(AnalysisEngineService.class);
    logger.addAppender(mockLogAppender);

    setUpRepositoryMocks();/*from w ww .jav a 2s .  co m*/

    LocalDateTime yesterday = TimeUtil.utcNow().minusDays(1).withHour(0).withMinute(1).withSecond(0);
    gamblingGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("gambling"), false,
                    new HashSet<>(Arrays.asList("poker", "lotto")),
                    new HashSet<>(Arrays.asList("Poker App", "Lotto App")), usString("Descr")));
    newsGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("news"), false,
                    new HashSet<>(Arrays.asList("refdag", "bbc")), Collections.emptySet(), usString("Descr")));
    gamingGoal = BudgetGoal.createNoGoInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("gaming"), false,
                    new HashSet<>(Arrays.asList("games")), Collections.emptySet(), usString("Descr")));
    socialGoal = TimeZoneGoal.createInstance(yesterday,
            ActivityCategory.createInstance(UUID.randomUUID(), usString("social"), false,
                    new HashSet<>(Arrays.asList("social")), Collections.emptySet(), usString("Descr")),
            Collections.emptyList());
    shoppingGoal = BudgetGoal
            .createInstance(yesterday,
                    ActivityCategory.createInstance(UUID.randomUUID(), usString("shopping"), false,
                            new HashSet<>(Arrays.asList("webshop")), Collections.emptySet(), usString("Descr")),
                    1);

    goalMap.put("gambling", gamblingGoal);
    goalMap.put("news", newsGoal);
    goalMap.put("gaming", gamingGoal);
    goalMap.put("social", socialGoal);
    goalMap.put("shopping", shoppingGoal);

    when(mockYonaProperties.getAnalysisService()).thenReturn(new AnalysisServiceProperties());

    when(mockActivityCategoryService.getAllActivityCategories()).thenReturn(getAllActivityCategories());
    when(mockActivityCategoryFilterService.getMatchingCategoriesForSmoothwallCategories(anySetOf(String.class)))
            .thenAnswer(new Answer<Set<ActivityCategoryDto>>() {
                @Override
                public Set<ActivityCategoryDto> answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();
                    @SuppressWarnings("unchecked")
                    Set<String> smoothwallCategories = (Set<String>) args[0];
                    return getAllActivityCategories().stream()
                            .filter(ac -> ac.getSmoothwallCategories().stream()
                                    .filter(smoothwallCategories::contains).findAny().isPresent())
                            .collect(Collectors.toSet());
                }
            });
    when(mockActivityCategoryFilterService.getMatchingCategoriesForApp(any(String.class)))
            .thenAnswer(new Answer<Set<ActivityCategoryDto>>() {
                @Override
                public Set<ActivityCategoryDto> answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();
                    String application = (String) args[0];
                    return getAllActivityCategories().stream()
                            .filter(ac -> ac.getApplications().contains(application))
                            .collect(Collectors.toSet());
                }
            });

    // Set up UserAnonymized instance.
    MessageDestination anonMessageDestinationEntity = MessageDestination
            .createInstance(PublicKeyUtil.generateKeyPair().getPublic());
    Set<Goal> goals = new HashSet<>(Arrays.asList(gamblingGoal, gamingGoal, socialGoal, shoppingGoal));
    deviceAnonEntity = DeviceAnonymized.createInstance(0, OperatingSystem.IOS, "Unknown", 0, Optional.empty());
    deviceAnonId = deviceAnonEntity.getId();
    userAnonEntity = UserAnonymized.createInstance(anonMessageDestinationEntity, goals);
    userAnonEntity.addDeviceAnonymized(deviceAnonEntity);
    userAnonDto = UserAnonymizedDto.createInstance(userAnonEntity);
    deviceAnonDto = DeviceAnonymizedDto.createInstance(deviceAnonEntity);
    userAnonId = userAnonDto.getId();
    userAnonZoneId = userAnonDto.getTimeZone();

    // Stub the UserAnonymizedService to return our user.
    when(mockUserAnonymizedService.getUserAnonymized(userAnonId)).thenReturn(userAnonDto);
    when(mockUserAnonymizedService.getUserAnonymizedEntity(userAnonId)).thenReturn(userAnonEntity);

    // Stub the GoalService to return our goals.
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, gamblingGoal.getId()))
            .thenReturn(gamblingGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, gamingGoal.getId()))
            .thenReturn(gamingGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, socialGoal.getId()))
            .thenReturn(socialGoal);
    when(mockGoalService.getGoalEntityForUserAnonymizedId(userAnonId, shoppingGoal.getId()))
            .thenReturn(shoppingGoal);

    // Mock the transaction helper
    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            invocation.getArgumentAt(0, Runnable.class).run();
            return null;
        }
    }).when(transactionHelper).executeInNewTransaction(any(Runnable.class));

    // Mock the week activity repository
    when(mockWeekActivityRepository.findOne(any(UUID.class), any(UUID.class), any(LocalDate.class)))
            .thenAnswer(new Answer<WeekActivity>() {
                @Override
                public WeekActivity answer(InvocationOnMock invocation) throws Throwable {
                    Optional<Goal> goal = goalMap.values().stream()
                            .filter(g -> g.getId() == invocation.getArgumentAt(1, UUID.class)).findAny();
                    if (!goal.isPresent()) {
                        return null;
                    }
                    return goal.get().getWeekActivities().stream().filter(
                            wa -> wa.getStartDate().equals(invocation.getArgumentAt(2, LocalDate.class)))
                            .findAny().orElse(null);
                }
            });

    // Mock device service and repo
    when(mockDeviceService.getDeviceAnonymized(userAnonDto, -1)).thenReturn(deviceAnonDto);
    when(mockDeviceService.getDeviceAnonymized(userAnonDto, deviceAnonId)).thenReturn(deviceAnonDto);
    when(mockDeviceAnonymizedRepository.getOne(deviceAnonId)).thenReturn(deviceAnonEntity);
}

From source file:com.amazonaws.util.awsclientgenerator.transform.C2jModelToGeneratorModelTransformer.java

void convertShapeReferences(C2jShape c2jShape, Shape shape) {

    Map<String, ShapeMember> shapeMemberMap = new LinkedHashMap<>();

    Set<String> required;
    if (c2jShape.getRequired() != null) {
        required = new LinkedHashSet<>(c2jShape.getRequired());
    } else {//w w w  .  j a  v a  2s  .  co m
        required = Collections.emptySet();
    }

    if (c2jShape.getMembers() != null) {
        c2jShape.getMembers().entrySet().stream().filter(entry -> !entry.getValue().isDeprecated())
                .forEach(entry -> {
                    ShapeMember shapeMember = convertMember(entry.getValue(),
                            required.contains(entry.getKey()));
                    shapeMemberMap.put(entry.getKey(), shapeMember);
                });
    }

    shape.setMembers(shapeMemberMap);

    // Shape is a List
    if (c2jShape.getMember() != null && !c2jShape.getMember().isDeprecated()) {
        shape.setListMember(convertMember(c2jShape.getMember(), false));
    }

    if (c2jShape.getKey() != null && !c2jShape.getKey().isDeprecated()) {
        shape.setMapKey(convertMember(c2jShape.getKey(), false));
    }

    if (c2jShape.getValue() != null && !c2jShape.getValue().isDeprecated()) {
        shape.setMapValue(convertMember(c2jShape.getValue(), false));
    }
}

From source file:nu.yona.server.goals.service.ActivityCategoryServiceTestConfiguration.java

@Test
public void addActivityCategory_default_updatesCache() {
    ActivityCategory gaming = ActivityCategory.createInstance(UUID.randomUUID(), usString("gaming"), false,
            new HashSet<>(Arrays.asList("games")), Collections.emptySet(), usString("Descr"));
    when(mockRepository.findOne(gaming.getId())).thenReturn(gaming);

    service.addActivityCategory(ActivityCategoryDto.createInstance(gaming));

    mockRepositoryFindAllResult.add(gaming);
    assertGetAllActivityCategoriesResult("gambling", "news", "gaming");
}

From source file:bg.fourweb.android.rss.Feed.java

/**
 * This constructor checks each argument for null value and replaces it with a default non-null value.
 * //from www. j  av a 2s .  c o  m
 * @param title
 * @param link
 * @param description
 */
@SuppressWarnings("unchecked")
public Feed(String title, String link, String description, String language, String copyright,
        String managingEditor, String webMaster, String pubDate, String lastBuildDate,
        List<Category> categories, String generator, String docs, Cloud cloud, int ttl, Image image,
        String rating, Collection<Integer> skipHours, Collection<String> skipDays, List<Item> items) {
    super();
    this.title = title != null ? title : StringUtils.EMPTY;
    this.link = link != null ? link : StringUtils.EMPTY;
    this.description = description != null ? description : StringUtils.EMPTY;
    this.language = language != null ? language : StringUtils.EMPTY;
    this.copyright = copyright != null ? copyright : StringUtils.EMPTY;
    this.managingEditor = managingEditor != null ? managingEditor : StringUtils.EMPTY;
    this.webMaster = webMaster != null ? webMaster : StringUtils.EMPTY;
    this.pubDate = pubDate != null ? pubDate : StringUtils.EMPTY;
    this.lastBuildDate = lastBuildDate != null ? lastBuildDate : StringUtils.EMPTY;
    this.categories = (List<Category>) (categories != null ? Collections.unmodifiableList(categories)
            : Collections.emptyList());
    this.generator = generator != null ? generator : StringUtils.EMPTY;
    this.docs = docs != null ? docs : StringUtils.EMPTY;
    this.cloud = cloud != null ? cloud : new Cloud();
    this.ttl = ttl > 0 ? ttl : Integer.MAX_VALUE;
    this.image = image != null ? image : new Image(StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY);
    this.rating = rating != null ? rating : StringUtils.EMPTY;
    this.skipHours = (Collection<Integer>) (skipHours != null ? skipHours : Collections.emptySet());
    this.skipDays = (Collection<String>) (skipDays != null ? skipDays : Collections.emptySet());
    this.items = (List<Item>) (items != null ? Collections.unmodifiableList(items) : Collections.emptyList());
}

From source file:cop.raml.utils.UtilsTest.java

@Test
public void testAsSet() {
    assertThat(Utils.asSet()).isSameAs(Collections.emptySet());
    assertThat(Utils.asSet(null, "", "   ")).isEmpty();
    assertThat(Utils.asSet("one")).containsExactly("one");
    assertThat(Utils.asSet("one", "two")).containsExactly("one", "two");
    assertThat(Utils.asSet("  one  ", "  two  ")).containsExactly("one", "two");
    assertThat(Utils.asSet("two", "one")).containsExactly("two", "one");
    assertThat(Utils.asSet("one", "one", "two", "two")).containsExactly("one", "two");
    assertThat(Utils.asSet("two", "", "  ", null, "one")).containsExactly("two", "one");
    assertThat(Utils.asSet("10", "2", "11", "1")).containsExactly("10", "2", "11", "1");
}

From source file:io.cloudslang.lang.systemtests.BindingScopeTest.java

@Test
public void testInputRequiredWithNullValue() throws Exception {
    URL resource = getClass().getResource("/yaml/check_weather_input_required.sl");
    final CompilationArtifact compilationArtifact = slang.compile(SlangSource.fromFile(resource.toURI()),
            new HashSet<SlangSource>());

    Map<String, Value> userInputs = new HashMap<>();
    userInputs.put("city", ValueFactory.create(null));
    Set<SystemProperty> systemProperties = Collections.emptySet();

    exception.expect(RuntimeException.class);

    exception.expectMessage(new BaseMatcher<String>() {
        public void describeTo(Description description) {
        }/*from w  ww .  j a  v  a  2s  .  c  om*/

        public boolean matches(Object o) {
            String message = o.toString();
            return message.contains("Error running: 'check_weather_input_required'.")
                    && message.contains("Input with name: 'city' is Required, but value is empty");
        }
    });
    triggerWithData(compilationArtifact, userInputs, systemProperties);
}

From source file:com.kennycason.kumo.LayeredWordCloudITest.java

private static Set<String> loadStopWords() {
    try {//from   ww  w.j  a  va  2  s . c  om
        final List<String> lines = IOUtils.readLines(getInputStream("text/stop_words.txt"));
        return new HashSet<>(lines);
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return Collections.emptySet();
}