org.hamcrest.collection.IsMapWithSize Java Examples
The following examples show how to use
org.hamcrest.collection.IsMapWithSize.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AirlinesAppTest.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@RunAsClient @Test(dataProvider = "formatProvider") public void testSchemaProperty(String type) { ValidatableResponse vr = callEndpoint(type); vr.body("components.schemas.User.properties", IsMapWithSize.aMapWithSize(10)); vr.body("components.schemas.User.properties.phone.example", equalTo("123-456-7890")); vr.body("components.schemas.User.properties.phone.description", equalTo("Telephone number to contact the user")); }
Example #2
Source File: BaseRequestTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldAddASingleParameter() { baseRequest.addParameter("name", "value"); final Map<String, Object> result = parameterBuilder.asDictionary(); assertThat(result, IsMapWithSize.aMapWithSize(1)); assertThat(result, IsMapContaining.hasEntry("name", (Object) "value")); }
Example #3
Source File: BaseRequestTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldAddParameters() { Map<String, Object> params = new HashMap<>(); params.put("name", "value"); params.put("asd", "123"); baseRequest.addParameters(params); final Map<String, Object> result = parameterBuilder.asDictionary(); assertThat(result, IsMapWithSize.aMapWithSize(2)); assertThat(result, IsMapContaining.hasEntry("name", (Object) "value")); assertThat(result, IsMapContaining.hasEntry("asd", (Object) "123")); }
Example #4
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldReturnEmptyQueryValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback?"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, is(notNullValue())); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #5
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldReturnEmptyFragmentValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback#"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, is(notNullValue())); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #6
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenQueryOrFragmentIsMissing() { String uriString = "https://my.website.com/some/page"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #7
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenQueryIsEmpty() { String uriString = "https://my.website.com/some/page?"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #8
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenQueryBeginsWithAmpersand() { String uriString = "https://my.website.com/some/page?&key_without_value"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #9
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenFragmentIsEmpty() { String uriString = "https://my.website.com/some/page#"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #10
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenFragmentBeginsWithAmpersand() { String uriString = "https://my.website.com/some/page#&key_without_value"; Uri uri = Uri.parse(uriString); final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #11
Source File: CallbackHelperTest.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldGetEmptyValuesWhenUriIsNull() { Uri uri = null; final Map<String, String> values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); assertThat(values, IsMapWithSize.<String, String>anEmptyMap()); }
Example #12
Source File: RealFlagRepositoryTest.java From vespa with Apache License 2.0 | 5 votes |
@Test public void test() { WireFlagDataList list = new WireFlagDataList(); list.flags = new ArrayList<>(); list.flags.add(new WireFlagData()); list.flags.get(0).id = "id1"; when(configServerApi.get(any(), eq(WireFlagDataList.class))).thenReturn(list); Map<FlagId, FlagData> allFlagData = repository.getAllFlagData(); assertThat(allFlagData, IsMapWithSize.aMapWithSize(1)); assertThat(allFlagData, IsMapContaining.hasKey(new FlagId("id1"))); }
Example #13
Source File: FlagDbFileTest.java From vespa with Apache License 2.0 | 4 votes |
@Test public void test() { Map<FlagId, FlagData> dataMap = new HashMap<>(); FlagId id1 = new FlagId("id1"); FlagData data1 = new FlagData(id1, new FetchVector()); dataMap.put(id1, data1); FlagId id2 = new FlagId("id2"); FlagData data2 = new FlagData(id2, new FetchVector()); dataMap.put(id2, data2); // Non-existing directory => empty map assertThat(flagDb.read(), IsMapWithSize.anEmptyMap()); // sync() will create directory with map content assertThat(flagDb.sync(dataMap), equalTo(true)); Map<FlagId, FlagData> readDataMap = flagDb.read(); assertThat(readDataMap, IsMapWithSize.aMapWithSize(2)); assertThat(readDataMap, IsMapContaining.hasKey(id1)); assertThat(readDataMap, IsMapContaining.hasKey(id2)); assertThat(getDbContent(), equalTo("{\"flags\":[{\"id\":\"id1\"},{\"id\":\"id2\"}]}")); // another sync with the same data is a no-op assertThat(flagDb.sync(dataMap), equalTo(false)); // Changing value of id1, removing id2, adding id3 dataMap.remove(id2); FlagData newData1 = new FlagData(id1, new FetchVector().with(FetchVector.Dimension.HOSTNAME, "h1")); dataMap.put(id1, newData1); FlagId id3 = new FlagId("id3"); FlagData data3 = new FlagData(id3, new FetchVector()); dataMap.put(id3, data3); assertThat(flagDb.sync(dataMap), equalTo(true)); Map<FlagId, FlagData> anotherReadDataMap = flagDb.read(); assertThat(anotherReadDataMap, IsMapWithSize.aMapWithSize(2)); assertThat(anotherReadDataMap, IsMapContaining.hasKey(id1)); assertThat(anotherReadDataMap, IsMapContaining.hasKey(id3)); assertThat(anotherReadDataMap.get(id1).serializeToJson(), equalTo("{\"id\":\"id1\",\"attributes\":{\"hostname\":\"h1\"}}")); assertThat(flagDb.sync(Collections.emptyMap()), equalTo(true)); assertThat(getDbContent(), equalTo("{\"flags\":[]}")); }