### Question:
Resource { public T get() { if (!isLoaded()) load(); return data; } protected  Resource(DataLoader<T> dataLoader); protected  Resource(DataLoader<T> dataLoader, boolean deferred); T get(); void set(T data); DataLoader<T> getDataLoader(); void setDataLoader(DataLoader<T> dataLoader); void reload(); void load(); void unload(); boolean isLoaded(); Resource<T> clone();  }### Answer:
@Test public void shouldCacheDataLoadedFromDataLoaderAndReturnSameData() { DataLoader dataLoaderA = new DataLoader<String>() { @Override public String load() { return new String("A"); } }; Resource<String> resource = new Resource<String>(dataLoaderA, true); String dataA = resource.get(); String dataB = resource.get(); assertThat(dataA, IsSame.sameInstance(dataB)); }
@Test public void shouldReturnDataFromDataLoader() { String data = "helloworld"; Resource<String> defferedResource = new Resource<String>(new StaticDataLoader<String>(data)); String actualData = defferedResource.get(); assertThat(actualData, IsEqual.equalTo(data)); }