コード例 #1
0
  @Test
  public void testCreateHeroProductForEmptyCategory() {
    when(heroProduct01.getCategory()).thenReturn(category01);
    when(heroProduct01.getIndexedType()).thenReturn(solrIndexedType01);
    when(defaultHeroProductDefinitionDao.findSolrHeroProductDefinitionsByCategory(
            category01, solrIndexedType01))
        .thenReturn(Collections.EMPTY_LIST);
    when(Boolean.valueOf(ctx.isNew(heroProduct01))).thenReturn(Boolean.TRUE);

    try {
      solrHeroProductValidator.onValidate(heroProduct01, ctx);
    } catch (final InterceptorException ie) {
      fail("should have created the hero product instead!");
    }
  }
コード例 #2
0
  @Test
  public void testCreateDuplicatedHeroProduct() {
    when(heroProduct01.getCategory()).thenReturn(category01);
    when(heroProduct01.getIndexedType()).thenReturn(solrIndexedType01);
    when(defaultHeroProductDefinitionDao.findSolrHeroProductDefinitionsByCategory(
            category01, solrIndexedType01))
        .thenReturn(Collections.singletonList(heroProduct01));
    when(Boolean.valueOf(ctx.isNew(heroProduct01))).thenReturn(Boolean.TRUE);

    try {
      solrHeroProductValidator.onValidate(heroProduct01, ctx);
      fail("should have thrown InterceptorException since hero product existed!");
    } catch (final InterceptorException ie) {
      // expected
    }
  }