AdConfiguration implements Serializable { public static AdConfiguration extractFromMap(Map<String, Object> map) { if (map == null) { return null; } Object adConfiguration = map.get(AD_CONFIGURATION_KEY); if (adConfiguration instanceof AdConfiguration) { return (AdConfiguration) adConfiguration; } return null; } @VisibleForTesting  AdConfiguration(final Context context); static AdConfiguration extractFromMap(Map<String, Object> map); @VisibleForTesting void setResponseString(String responseString); long getBroadcastIdentifier();  }
@Test public void extractFromMap_shouldReturnValidAdConfiguration() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put(AdFetcher.AD_CONFIGURATION_KEY, subject); AdConfiguration returnValue = AdConfiguration.extractFromMap(map); assertThat(returnValue).isEqualTo(subject); }
@Test public void extractFromMap_withNullMap_shouldReturnNull() throws Exception { AdConfiguration returnValue = AdConfiguration.extractFromMap(null); assertThat(returnValue).isEqualTo(null); }
@Test public void extractFromMap_withNonAdConfigurationObjectInMap_shouldReturnNull() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put(AdFetcher.AD_CONFIGURATION_KEY, "not_an_ad_configuration"); AdConfiguration returnValue = AdConfiguration.extractFromMap(map); assertThat(returnValue).isEqualTo(null); }