コード例 #1
0
  @Test
  public void asListの引数にNameValueObject配列型のnullを渡した場合_nullが返されること() {

    // Setup
    NameValueObject[] ary = null;

    // Exercise
    List<NameValueObject> actual = NameValueObject.asList(ary);

    // Verify
    assertThat(actual, is(nullValue()));
  }
コード例 #2
0
  @Test
  public void asListの引数に空のMapを渡した場合_nullが返されること() {

    // Setup
    Map<String, String> src = new HashMap<String, String>(0);

    // Exercise
    List<NameValueObject> actual = NameValueObject.asList(src);

    // Verify
    assertThat(actual, is(nullValue()));
  }
コード例 #3
0
  @Test
  public void toStringを呼び出すと文字列表現が返されること() {

    // Setup
    NameValueObject sut = new NameValueObject("name", "value"); // $NON-NLS-1$ //$NON-NLS-2$

    // Exercise
    String actual = sut.toString();

    // Verify
    assertThat(
        actual,
        is(
            equalTo(
                "NameValueObject["
                    + File.separator
                    + "  name=name"
                    + File.separator // $NON-NLS-1$
                    + "  value=value"
                    + File.separator
                    + "]")));
  }
コード例 #4
0
  @Test
  public void asListの引数にNameValueObjectの配列を渡した場合_NameValueObjectのListが生成されて返されること() {

    // Setup
    NameValueObject[] ary = new NameValueObject[5];
    ary[0] = new NameValueObject("Name1", "Value1"); // $NON-NLS-1$ //$NON-NLS-2$
    ary[1] = new NameValueObject("Name2", "Value2"); // $NON-NLS-1$ //$NON-NLS-2$
    ary[2] = new NameValueObject("Name3", "Value3"); // $NON-NLS-1$ //$NON-NLS-2$
    ary[3] = new NameValueObject("Name4", "Value4"); // $NON-NLS-1$ //$NON-NLS-2$
    ary[4] = new NameValueObject("Name5", "Value5"); // $NON-NLS-1$ //$NON-NLS-2$

    // Exercise
    List<NameValueObject> actual = NameValueObject.asList(ary);

    // Verify
    assertThat(actual.size(), is(ary.length));
    for (int i = 0; i < ary.length; i++) {
      assertThat(actual.get(i).getName(), is(equalTo(ary[i].getName())));
      assertThat(actual.get(i).getValue(), is(equalTo(ary[i].getValue())));
    }

    assertThat(NameValueObject.asList((NameValueObject[]) null), is(nullValue()));
    assertThat(NameValueObject.asList(new NameValueObject[0]).isEmpty(), is(true));
  }
コード例 #5
0
  @Test
  public void asListの引数にMapを渡した場合_Mapの内容からNameValueObjectのListが生成されて返されること() {

    // Setup
    Map<String, String> src = new HashMap<String, String>();
    src.put("param1", "value1"); // $NON-NLS-1$ //$NON-NLS-2$
    src.put("param2", "value2"); // $NON-NLS-1$ //$NON-NLS-2$
    src.put("param3", "value3"); // $NON-NLS-1$ //$NON-NLS-2$
    src.put("param4", "value4"); // $NON-NLS-1$ //$NON-NLS-2$

    // Exercise
    List<NameValueObject> actual = NameValueObject.asList(src);

    // Verify
    assertThat(actual.size(), is(src.size()));
  }