congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JsonMap.getString
Code IndexAdd Tabnine to your IDE (free)

How to use
getString
method
in
de.otto.edison.testsupport.util.JsonMap

Best Java code snippets using de.otto.edison.testsupport.util.JsonMap.getString (Showing top 11 results out of 315)

origin: otto-de/edison-microservice

public String getString(final String key, final String defaultValue) {
  final String result = getString(key);
  return result != null ? result : defaultValue;
}
origin: otto-de/edison-microservice

public Instant getInstant(final String key) {
  if (jsonObject == null) {
    throw new NullPointerException("json object is null");
  }
  if (is(Map.class)) {
    final String value = getString(key);
    return value != null ? parse(value) : null;
  } else {
    throw new IllegalArgumentException("not a map but a " + jsonObject.getClass().getSimpleName());
  }
}
origin: otto-de/edison-microservice

@Test
public void shouldGetNullForMissingString() {
  final Map<String, ?> map = singletonMap("key", null);
  assertThat(jsonMapFrom(map).getString("key"), is(nullValue()));
  assertThat(jsonMapFrom(map).getString("doesnotexist"), is(nullValue()));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetString() {
  final Map<String, ?> map = singletonMap("key", "value");
  assertThat(jsonMapFrom(map).getString("key"), is("value"));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetStringFromLong() {
  final Map<String, ?> map = singletonMap("key", 2L);
  assertThat(jsonMapFrom(map).getString("key"), is("2"));
}
origin: otto-de/edison-microservice

@Test
public void shouldFallbackOnDefaultString() {
  final JsonMap empty = jsonMapFrom(new HashMap<String, Object>());
  assertThat(empty.getString("key", "default"), is("default"));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetStringFromDouble() {
  final Map<String, ?> map = singletonMap("key", 2.0d);
  assertThat(jsonMapFrom(map).getString("key"), is("2.0"));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetStringFromInteger() {
  final Map<String, ?> map = singletonMap("key", 1);
  assertThat(jsonMapFrom(map).getString("key"), is("1"));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetInnerValueByDottedKeys() {
  /**
   * {
   * "outer" : {
   *      "innter": {
   *          "key" : "value"
   *      }
   * }
   */
  final Map<String, ?> inner = singletonMap("key", "value");
  final Map<String, ?> map = singletonMap("outer", singletonMap("inner", inner));
  assertThat(jsonMapFrom(map).get("outer.inner").getString("key"), is("value"));
}
origin: otto-de/edison-microservice

@Test
public void shouldGetStringFromBoolean() {
  final Map<String, ?> map = new HashMap<String, Boolean>() {{
    put("somethingTrue", TRUE);
    put("somethingFalse", FALSE);
  }};
  assertThat(jsonMapFrom(map).getString("somethingTrue"), is("true"));
  assertThat(jsonMapFrom(map).getString("somethingFalse"), is("false"));
}
origin: otto-de/edison-microservice

@Test
public void shouldCreateStatusRepresentationWithDetailInclUrl() {
  // given
  final StatusRepresentation json = statusRepresentationOf(
      applicationStatus(
          mock(ApplicationInfo.class),
          mock(ClusterInfo.class),
          mock(SystemInfo.class),
          mock(VersionInfo.class),
          mock(TeamInfo.class),
          singletonList(
              statusDetail("someDetail", OK, "some message", link("item", "http://example.org/some/url", "some title"))
          )
      )
  );
  // then
  assertThat(json.application.status, is(OK));
  final JsonMap jsonMap = jsonMapFrom(json.application.statusDetails.get("someDetail"));
  final JsonMap link = jsonMap.get("links").asListOf(JsonMap.class).get(0);
  assertThat(link.getString("href"), is("http://example.org/some/url"));
  assertThat(link.getString("title"), is("some title"));
  assertThat(link.getString("rel"), is("item"));
}
de.otto.edison.testsupport.utilJsonMapgetString

Popular methods of JsonMap

  • get
  • getBoolean
  • getDouble
  • getInt
  • getLong
  • jsonMapFrom
  • <init>
  • asListOf
  • getDate
  • getFloat
  • getInstant
  • is
  • getInstant,
  • is,
  • remove,
  • toString

Popular in Java

  • Making http requests using okhttp
  • putExtra (Intent)
  • getContentResolver (Context)
  • scheduleAtFixedRate (Timer)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now