Examples of UserPrefs


Examples of org.apache.shindig.gadgets.UserPrefs

    spec = new GadgetSpec(Uri.parse("#"), DEFAULT_XML);
  }

  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);

    assertEquals(DEFAULT_VALUE,
        substituter.getSubstitution(Type.USER_PREF, DEFAULT_NAME));
    assertEquals(USER_VALUE,
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

        substituter.getSubstitution(Type.USER_PREF, OVERRIDE_NAME));
  }

  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);
    assertEquals(ESCAPED_USER_VALUE,
        substituter.getSubstitution(Type.USER_PREF, USER_NAME));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

                 "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse("#"), xml);
    GadgetContext context = new GadgetContext() {
      @Override
      public UserPrefs getUserPrefs() {
        return new UserPrefs(ImmutableMap.of("foo", "shindig"));
      }
    };

    spec = substituter.substitute(context, spec);
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

    addParam(uri, Param.COUNTRY.getKey(), context.getLocale().getCountry(), useTpl, false);
    addParam(uri, Param.DEBUG.getKey(), context.getDebug() ? "1" : "0", useTpl, false);
    addParam(uri, Param.NO_CACHE.getKey(), context.getIgnoreCache() ? "1" : "0", useTpl, false);
   
    // Add all UserPrefs
    UserPrefs prefs = context.getUserPrefs();
    for (UserPref up : gadget.getSpec().getUserPrefs()) {
      String name = up.getName();
      String data = prefs.getPref(name);
      if (data == null) {
        data = up.getDefaultValue();
      }
     
      boolean upInFragment = !view.needsUserPrefSubstitution();
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

        Iterator i = prefs.keys();
        while (i.hasNext()) {
            String key = (String) i.next();
            p.put(key, prefs.getString(key));
        }
        return new UserPrefs(p);
    }
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

  }

  @Test
  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);

    assertEquals(DEFAULT_VALUE,
        substituter.getSubstitution(Type.USER_PREF, DEFAULT_NAME));
    assertEquals(USER_VALUE,
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

  }

  @Test
  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);
    assertEquals(ESCAPED_USER_VALUE,
        substituter.getSubstitution(Type.USER_PREF, USER_NAME));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

      expect(up.getDefaultValue()).andReturn(specPref.getValue()).anyTimes();
      replay(up);
      specPrefList.add(up);
    }
    expect(spec.getUserPrefs()).andReturn(specPrefList).anyTimes();
    UserPrefs ctxPrefs = new UserPrefs(inPrefs);
    expect(context.getUserPrefs()).andReturn(ctxPrefs).anyTimes();
    expect(view.needsUserPrefSubstitution()).andReturn(needsPrefSubst).anyTimes();
   
    // Link all the mocks together
    expect(spec.getModulePrefs()).andReturn(modulePrefs).anyTimes();
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.UserPrefs

      expect(up.getDefaultValue()).andReturn(specPref.getValue()).anyTimes();
      replay(up);
      specPrefMap.put(up.getName(),up);
    }
    expect(spec.getUserPrefs()).andReturn(specPrefMap).anyTimes();
    UserPrefs ctxPrefs = new UserPrefs(inPrefs);
    expect(context.getUserPrefs()).andReturn(ctxPrefs).anyTimes();
    expect(context.getParameter(Param.REFRESH.getKey())).andReturn(null).anyTimes();
    expect(view.needsUserPrefSubstitution()).andReturn(needsPrefSubst).anyTimes();
   
    // Link all the mocks together
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.