@Test public void testPutSingleKey() throws Exception { final String expected = "putSingleValue"; LocalLookupConfig conf = new LocalLookupConfig(); LocalStore localStore = new LocalStore(conf); localStore.put("putSingleKey", expected); Optional<String> value = localStore.get("putSingleKey"); localStore.close(); assertTrue(value.isPresent()); assertEquals(expected, value.get()); }
@Test public void testGetSingleKey() throws Exception { final String expected = "value1"; LocalLookupConfig conf = new LocalLookupConfig(); conf.values = ImmutableMap.of("key1", "value1", "key2", "value2", "key3", "value3"); LocalStore localStore = new LocalStore(conf); Optional<String> value = localStore.get("key1"); localStore.close(); assertTrue(value.isPresent()); assertEquals(expected, value.get()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_screen); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Intent intent = getIntent(); int moviePosition = intent.getIntExtra(MovieListAdapter.MOVIE_POSITION, 0); currentMovie = LocalStore.getMovies().get(moviePosition); TextView movieTitle = (TextView) findViewById(R.id.movieTitle); TextView movieGenre = (TextView) findViewById(R.id.movieGenre); TextView movieDescr = (TextView) findViewById(R.id.movieDescription); movieTitle.setText(currentMovie.getTitle()); // movieGenre.setText(currentMovie.get); movieDescr.setText(((Integer) currentMovie.getYear()).toString()); // implement viewList of reviews Button addRating = (Button) findViewById(R.id.addRatingButton); addRating.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { review(currentMovie.getId()); } }); }
@Test public void testGetMultipleKeys() throws Exception { List<String> keys = ImmutableList.of("key1", "key2", "key3", "key4"); Map<String, Optional<?>> expected = ImmutableMap.of( "key1", Optional.of("value1"), "key2", Optional.of("value2"), "key3", Optional.of("value3"), "key4", Optional.absent()); LocalLookupConfig conf = new LocalLookupConfig(); conf.values = ImmutableMap.of("key1", "value1", "key2", "value2", "key3", "value3"); LocalStore localStore = new LocalStore(conf); Map<String, Optional<String>> values = localStore.get(keys); localStore.close(); assertEquals(keys.size(), values.size()); assertEquals(expected.toString(), values.toString()); }