FlavorEntity extends VisibleModelEntity { public void setState(FlavorState state) { EntityStateValidator.validateStateChange(this.getState(), state, FlavorState.PRECONDITION_STATES); this.state = state; }  String getKind(); void setKind(String kind); List<QuotaLineItemEntity> getCost(); void setCost(List<QuotaLineItemEntity> cost); FlavorState getState(); void setState(FlavorState state); Flavor toApiRepresentation();  }
@Test(dataProvider = "getSetValidStateParams") public void testSetValidState(FlavorState originalState, FlavorState newState) throws Exception { FlavorEntity flavor = new FlavorEntity(); flavor.setState(originalState); flavor.setState(newState); }
@Test(dataProvider = "getSetInvalidStateParams") public void testSetInvalidState(FlavorState originalState, FlavorState newState) throws Exception { FlavorEntity flavor = new FlavorEntity(); flavor.setState(originalState); try { flavor.setState(newState); fail("setState should throw exception"); } catch (IllegalStateException ex) { assertThat(ex.getMessage(), is(String.format("%s -> %s", originalState, newState))); } }