Ejemplo n.º 1
0
  @Test
  public void getProperties() throws Exception {
    final ModuleURN input = new ModuleURN("test:prov:me:A");
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("first", BigDecimal.TEN);
    m.put("second", "next");
    m.put("third", 909);
    // Test a non-empty and an empty map.
    List<Map<String, Object>> maps = Arrays.asList(m, new HashMap<String, Object>());
    for (Map<String, Object> map : maps) {
      final Map<String, Object> output = map;
      testAPI(
          new WSTester<Map<String, Object>>() {
            @Override
            protected Map<String, Object> invokeApi(boolean isNullParams) throws Exception {
              return getClient().getProperties(isNullParams ? null : input);
            }

            @Override
            protected Map<String, Object> setReturnValue(boolean isNullParams) {
              getMockSAService()
                  .setPropertiesOut(isNullParams ? null : new MapWrapper<String, Object>(output));
              return isNullParams ? null : output;
            }

            @Override
            protected void verifyInputParams(boolean isNullParams) throws Exception {
              verifyEquals(isNullParams ? null : input, getMockSAService().getURN());
            }
          });
      resetServiceParameters();
    }
  }
Ejemplo n.º 2
0
  @Test
  public void setProperties() throws Exception {
    final ModuleURN input1 = new ModuleURN("test:prov:me:A");
    final Map<String, Object> i2 = new HashMap<String, Object>();
    i2.put("first", BigDecimal.ONE);
    i2.put("second", "mnext");
    i2.put("third", 999);
    // Test a non-empty and an empty map.
    List<Map<String, Object>> inputs = Arrays.asList(i2, new HashMap<String, Object>());
    final Map<String, Object> out = new HashMap<String, Object>();
    out.put("first", BigDecimal.TEN);
    out.put("second", "next");
    out.put("third", 909);
    // Test a non-empty and an empty map.
    List<Map<String, Object>> outputs = Arrays.asList(out, new HashMap<String, Object>());
    for (int i = 0; i < inputs.size(); i++) {
      final Map<String, Object> input2 = inputs.get(i);
      final Map<String, Object> output = outputs.get(i);
      testAPI(
          new WSTester<Map<String, Object>>() {
            @Override
            protected Map<String, Object> invokeApi(boolean isNullParams) throws Exception {
              return getClient()
                  .setProperties(isNullParams ? null : input1, isNullParams ? null : input2);
            }

            @Override
            protected Map<String, Object> setReturnValue(boolean isNullParams) {
              getMockSAService()
                  .setPropertiesOut(isNullParams ? null : new MapWrapper<String, Object>(output));
              return isNullParams ? null : output;
            }

            @Override
            protected void verifyInputParams(boolean isNullParams) throws Exception {
              assertEquals(isNullParams ? null : input1, getMockSAService().getURN());
              MapWrapper<String, Object> mapWrapper = getMockSAService().getPropertiesIn();
              verifyEquals(
                  isNullParams ? null : input2, mapWrapper == null ? null : mapWrapper.getMap());
            }
          });
      resetServiceParameters();
    }
  }