FacetFieldModel implements IModel<FacetField> { @Override public FacetField getObject() { return fieldsModel.getFacetField(facetNameModel.getObject()); } FacetFieldModel(IModel<String> facetNameModel, FacetFieldsService service, IModel<QueryFacetsSelection> selectionModel, int valueLimit);  FacetFieldModel(IModel<String> facetNameModel, FacetFieldsModel fieldsModel); @Override FacetField getObject(); @Override void detach();  }
@Test public void testGetObject() { final FacetFieldModel instance = new FacetFieldModel(Model.of("facet4"), new FacetFieldsModel(service, new ListModel<>(ImmutableList.of("facet4")), selectionModel, Model.of(20))); context.checking(new Expectations() { { oneOf(service).getFacetFields(selection, ImmutableList.of("facet4"), 20); will(returnValue(Arrays.asList( new FacetField("facet4") ))); } }); final FacetField result = instance.getObject(); assertEquals("facet4", result.getName()); final FacetField result2 = instance.getObject(); assertEquals(result, result2); }
@Test public void testGetObjectNotIncluded() { final FacetFieldModel instance = new FacetFieldModel(Model.of("facet4"), new FacetFieldsModel(service, new ListModel<>(ImmutableList.of("facet4")), selectionModel, Model.of(20))); context.checking(new Expectations() { { oneOf(service).getFacetFields(selection, ImmutableList.of("facet4"), 20); will(returnValue(Collections.emptyList())); } }); final FacetField result = instance.getObject(); assertNull(result); }