private void searchInLabelTypes(String filter) {
   boolean limited = (filter.length() < 3);
   for (LabelType type : getLabelsMap().keySet()) {
     String name = StringUtils.deleteWhitespace(type.getName().toLowerCase());
     if (name.contains(filter)) {
       setFilterPairLabelType(type, limited);
     } else {
       searchInLabels(type, filter);
     }
   }
 }
 private void searchInLabels(LabelType type, String filter) {
   for (Label label : getLabelsMap().get(type)) {
     String name = StringUtils.deleteWhitespace(label.getName().toLowerCase());
     if (name.contains(filter)) {
       addLabel(type, label);
       if ((filter.length() < 3) && (getListMatching().size() > 9)) {
         return;
       }
     }
   }
 }
 @Test
 public void testPathTemplate() throws Exception {
   Template template = cfg.getTemplate(getTemplatePath("path.html"));
   Map<String, Object> params = new HashMap<String, Object>();
   Site site = new Site();
   site.setId(2L);
   params.put(GlobalVariable.SITE.toString(), site);
   String value = process(template, params);
   value = StringUtils.deleteWhitespace(value);
   Assert.assertEquals("test-path-include", value);
 }
  @Override
  public List<FilterPair> getMatching(String filter) {
    getListMatching().clear();
    if ((filter != null) && (!filter.isEmpty())) {
      filter = StringUtils.deleteWhitespace(filter.toLowerCase());
      searchInCriterionTypes(filter);
      searchInLabelTypes(filter);
      searchInResources(filter);
    }

    addNoneFilter();
    return getListMatching();
  }
 private void searchInResources(String filter) {
   Map<Class<?>, List<Resource>> mapResources = databaseSnapshots.snapshotMapResources();
   for (Class<?> className : mapResources.keySet()) {
     for (Resource resource : mapResources.get(className)) {
       String name = StringUtils.deleteWhitespace(resource.getName().toLowerCase());
       if (name.contains(filter)) {
         addResource(className, resource);
         if ((filter.length() < 3) && (getListMatching().size() > 9)) {
           return;
         }
       }
     }
   }
 }
 private void searchInCriterions(CriterionType type, String filter) {
   List<Criterion> list = getMapCriterions().get(type);
   if (list == null) {
     return;
   }
   for (Criterion criterion : list) {
     String name = StringUtils.deleteWhitespace(criterion.getName().toLowerCase());
     if (name.contains(filter)) {
       addCriterion(type, criterion);
       if ((filter.length() < 3) && (getListMatching().size() > 9)) {
         return;
       }
     }
   }
 }
  @Test
  public void testChannelTemplate() throws Exception {
    Template template = cfg.getTemplate(getTemplatePath("channel.html"));

    Map<String, Object> params = new HashMap<String, Object>();
    Site site = new Site();
    site.setId(2L);
    params.put(GlobalVariable.SITE.toString(), site);
    Channel channel = new Channel();
    channel.setId(1L);
    params.put(GlobalVariable.CHANNEL.getVariable(), channel);
    params.put(GlobalVariable.TASK_ID.getVariable(), "1111-2222-3333-4444");
    String value = process(template, params);
    value = StringUtils.deleteWhitespace(value);
    Assert.assertEquals("test-channel-includetest-channel-includetest-channel-include", value);
  }
 @SuppressWarnings("unchecked")
 @Test
 public void testCacheTemplate() throws Exception {
   Template template = cfg.getTemplate(getTemplatePath("cache.html"));
   Map<String, Object> params = new HashMap<String, Object>();
   Site site = new Site();
   site.setId(2L);
   params.put(GlobalVariable.SITE.toString(), site);
   Channel channel = new Channel();
   channel.setId(1L);
   params.put(GlobalVariable.CHANNEL.getVariable(), channel);
   params.put(GlobalVariable.TASK_ID.getVariable(), "1111-2222-3333-4444");
   includeCache = Mockito.mock(Cacheable.class);
   Mockito.when(includeCache.get(Mockito.anyString())).thenReturn("hello-cache");
   params.put(GlobalVariable.INCLUDE_CACHE.getVariable(), includeCache);
   String value = process(template, params);
   value = StringUtils.deleteWhitespace(value);
   Assert.assertEquals("hello-cache", value);
 }
Esempio n. 9
0
  @Override
  public void init() {
    //////// BUTTONS
    cmng = new ComponentManager();

    for (int i = 0; i < BUTTONS_NAME.length; i++) {
      String name = BUTTONS_NAME[i];
      final SButton button =
          SButton.getCenterButtonWithGap(
              name,
              Experiment.WIDTH,
              Experiment.HEIGHT,
              BUTTONS_WIDTH,
              BUTTONS_HEIGHT,
              BUTTONS_PLUS_X,
              i * BUTTONS_HEIGHT + BUTTONS_PLUS_Y,
              Color.YELLOW,
              Type.GHOSTRY);
      final RectangularShape shape = button.getShape();
      cmng.addComponent(StringUtils.deleteWhitespace(name).toLowerCase(), button);

      marksButton[i] = new Point((int) (shape.getMinX() - BUTTONS_HEIGHT), (int) (shape.getMinY()));
    }
  }
Esempio n. 10
0
 public static final String getPhonesAsString(List<String> phones) {
   String result = Arrays.toString(phones.toArray());
   result = StringUtils.deleteWhitespace(result);
   return result.substring(1, result.length() - 1);
 }
 /**
  * *
  * <li><b>Remove/Delete</b> - removes part of a String.
  *
  *     <p>Removes all occurrences of a character from within the source string.
  *
  *     <p>Deletes all whitespaces from a String as defined by
  */
 @Test
 public void testRemoveDeleteStringUtils() {
   System.out.println(strOne + ":" + strOne.length());
   System.out.println(StringUtils.remove(strOne, 'd'));
   System.out.println(StringUtils.deleteWhitespace("    " + strOne + "    "));
 }