示例#1
0
 @Test
 public void testProductIsNotDetachedByStockIsNull() {
   spyProduct.setId(0L);
   spyProduct.setStock(null);
   when(mockSubCategory.isDetached()).thenReturn(false);
   when(mockContent.isDetached()).thenReturn(false);
   when(mockOption.isDetached()).thenReturn(false);
   assertFalse("Detached", spyProduct.isDetached());
   verify(spyProduct, times(1)).isDetached();
   verify(mockStock, never()).isDetached();
   verify(mockSubCategory, times(1)).isDetached();
   verify(mockContent, times(1)).isDetached();
   verify(mockOption, times(1)).isDetached();
 }
示例#2
0
 @Test
 public void testProductIsDetachedBySubCategory() {
   spyProduct.setId(0L);
   when(mockStock.isDetached()).thenReturn(false);
   when(mockSubCategory.isDetached()).thenReturn(true);
   when(mockContent.isDetached()).thenReturn(false);
   when(mockOption.isDetached()).thenReturn(false);
   assertTrue("Detached", spyProduct.isDetached());
   verify(spyProduct, times(1)).isDetached();
   verify(mockStock, times(1)).isDetached();
   verify(mockSubCategory, times(1)).isDetached();
   verify(mockContent, times(1)).isDetached();
   verify(mockOption, times(1)).isDetached();
 }