### Question:
ViewProvider implements ViewReader<V> { @Override public V readView(ViewDescriptor request) throws IOException { List<V> views = readViews(ImmutableList.of(request)); return views.isEmpty() ? viewFormatter.emptyView() : views.get(0); } ViewProvider(ViewPermissionChecker viewPermissionChecker,
        ViewValueReader viewValueReader,
        TenantViewsProvider viewModel,
        ViewFormatter<V> viewFormatter,
        JsonViewMerger merger,
        StaleViewFieldStream staleViewFieldStream,
        long viewMaxSizeInBytes); @Override V readView(ViewDescriptor request); @Override List<V> readViews(List<ViewDescriptor> request);  }### Answer:
@Test public void testReadView() throws Exception { ObjectMapper mapper = new ObjectMapper(); TenantId tenantId = new TenantId("tenantId"); ViewPathKeyProvider viewPathKeyProvider = new StringHashcodeViewPathKeyProvider(); ViewValueWriter viewValueWriter = new ViewValueWriter(new ViewValueStore(store, viewPathKeyProvider)); ViewValueWriter.Transaction transaction = viewValueWriter.begin(new TenantIdAndCentricId(tenantId, new Id(1))); transaction.set(new ObjectId("view", new Id(2)), viewPathKeyProvider.modelPathHashcode("1"), new ObjectId[]{new ObjectId("view", new Id(2))}, new ViewValue(new long[]{1}, mapper.writeValueAsBytes(ImmutableMap.of("title", "booya"))), 1); viewValueWriter.commit(transaction); ViewDescriptor request = new ViewDescriptor(new TenantIdAndCentricId(tenantId, new Id(1)), new Id(1), new ObjectId("view", new Id(2))); ViewResponse readView = (ViewResponse) viewProvider.readView(request); System.out.println("Result:" + readView + " " + readView.getClass()); ObjectNode viewBody = readView.getViewBody(); Assert.assertNotNull(viewBody); Assert.assertEquals(viewBody.get("title").asText(), "booya"); }
@Test public void testPoisonView() throws Exception { viewProvider = new ViewProvider(viewPermissionChecker, viewValueReader, tenantViewsProvider, viewFormatter, merger, staleViewFieldStream, 1); ObjectMapper mapper = new ObjectMapper(); TenantId tenantId = new TenantId("tenantId"); ViewPathKeyProvider viewPathKeyProvider = new StringHashcodeViewPathKeyProvider(); ViewValueWriter viewValueWriter = new ViewValueWriter(new ViewValueStore(store, viewPathKeyProvider)); ViewValueWriter.Transaction transaction = viewValueWriter.begin(new TenantIdAndCentricId(tenantId, new Id(1))); transaction.set(new ObjectId("view", new Id(2)), viewPathKeyProvider.modelPathHashcode("1"), new ObjectId[]{new ObjectId("view", new Id(2))}, new ViewValue(new long[]{1}, mapper.writeValueAsBytes(ImmutableMap.of("title", "booya"))), 1); viewValueWriter.commit(transaction); ViewDescriptor request = new ViewDescriptor(new TenantIdAndCentricId(tenantId, new Id(1)), new Id(1), new ObjectId("view", new Id(2))); ViewResponse readView = (ViewResponse) viewProvider.readView(request); System.out.println("Result:" + readView + " " + readView.getClass()); }