Skip to content

Instantly share code, notes, and snippets.

@ksiwonia
Created February 12, 2013 13:58
Show Gist options
  • Save ksiwonia/4770053 to your computer and use it in GitHub Desktop.
Save ksiwonia/4770053 to your computer and use it in GitHub Desktop.
public class AvgLaborCostCalcForOrderDetailsHooksTest {
private AvgLaborCostCalcForOrderDetailsHooks orderDetailsHooks;
@Mock
private ViewDefinitionState view;
@Mock
private FieldComponent averageLaborHourlyCost;
@Mock
private WindowComponentState window;
@Mock
private Ribbon ribbon;
@Mock
private RibbonGroup hourlyCostNorms;
@Mock
private RibbonActionItem copyToOperationsNorms;
@Before
public void init() {
orderDetailsHooks = new AvgLaborCostCalcForOrderDetailsHooks();
MockitoAnnotations.initMocks(this);
when(view.getComponentByReference("window")).thenReturn((ComponentState) window);
when(window.getRibbon()).thenReturn(ribbon);
when(ribbon.getGroupByName("hourlyCostNorms")).thenReturn(hourlyCostNorms);
when(window.getRibbon().getGroupByName("hourlyCostNorms").getItemByName("copyToOperationsNorms")).thenReturn(
copyToOperationsNorms);
when(view.getComponentByReference(AVERAGE_LABOR_HOURLY_COST)).thenReturn(averageLaborHourlyCost);
}
@Test
public void shouldEnabledButtonForCopyNorms() throws Exception {
// given
String averageLaborHourlyCostValue = "50";
when(averageLaborHourlyCost.getFieldValue()).thenReturn(averageLaborHourlyCostValue);
// when
orderDetailsHooks.enabledButtonForCopyNorms(view);
// then
Mockito.verify(copyToOperationsNorms).setEnabled(true);
}
@Test
public void shouldDisbaleButtonForCopyNorms() throws Exception {
// given
String averageLaborHourlyCostValue = "";
when(averageLaborHourlyCost.getFieldValue()).thenReturn(averageLaborHourlyCostValue);
// when
orderDetailsHooks.enabledButtonForCopyNorms(view);
// then
Mockito.verify(copyToOperationsNorms).setEnabled(false);
}
@After
public void flush() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment