@Test public void setState() throws Exception { EsInstance inst = new EsInstance(); inst.setState(State.RUNNING.toString()); Assert.assertEquals(inst.getState(), State.RUNNING.toString()); inst.setState(State.RUNNING.toString()); Assert.assertEquals(inst.getState(), State.RUNNING.toString()); inst.setState(State.STOPPED.toString()); Assert.assertEquals(inst.getState(), State.STOPPED.toString()); inst.setState(State.RUNNING.toString()); Assert.assertEquals(inst.getState(), State.RUNNING.toString()); inst.setState(State.TERMINATED.toString()); Assert.assertEquals(inst.getState(), State.TERMINATED.toString()); thrown.expect(InvalidStateTransitionException.class); inst.setState(State.RUNNING.toString()); }
public void setState(String state) throws InvalidStateTransitionException { if (StringUtils.isEmpty(this.state)) { this.state = state; } else if (!StringUtils.equals(this.state, state)) { if (STATE_TRANSITION_MAP.containsKey(this.state) && STATE_TRANSITION_MAP.get(this.state) .contains(state)) { this.state = state; } else { throw new InvalidStateTransitionException( String.format("Invalid transit state from %s to %s", this.state, state)); } } }
EsInstance implements EsDocument { public void setState(String state) throws InvalidStateTransitionException { if (StringUtils.isEmpty(this.state)) { this.state = state; } else if (!StringUtils.equals(this.state, state)) { if (STATE_TRANSITION_MAP.containsKey(this.state) && STATE_TRANSITION_MAP.get(this.state) .contains(state)) { this.state = state; } else { throw new InvalidStateTransitionException( String.format("Invalid transit state from %s to %s", this.state, state)); } } } }
EsInstance implements EsDocument { public void setState(String state) throws InvalidStateTransitionException { if (StringUtils.isEmpty(this.state)) { this.state = state; } else if (!StringUtils.equals(this.state, state)) { if (STATE_TRANSITION_MAP.containsKey(this.state) && STATE_TRANSITION_MAP.get(this.state) .contains(state)) { this.state = state; } else { throw new InvalidStateTransitionException( String.format("Invalid transit state from %s to %s", this.state, state)); } } }  }
EsInstance implements EsDocument { public void setState(String state) throws InvalidStateTransitionException { if (StringUtils.isEmpty(this.state)) { this.state = state; } else if (!StringUtils.equals(this.state, state)) { if (STATE_TRANSITION_MAP.containsKey(this.state) && STATE_TRANSITION_MAP.get(this.state) .contains(state)) { this.state = state; } else { throw new InvalidStateTransitionException( String.format("Invalid transit state from %s to %s", this.state, state)); } } }  int getCached(); void setCached(int cached); long getVersion(); void setVersion(long version); List<String> getSecurityGroups(); void setSecurityGroups(List<String> securityGroups); Map<String, String> getTags(); void setTags(Map<String, String> tags); List<String> getSecurityGroupIds(); void setSecurityGroupIds(List<String> securityGroupIds); String getId(); void setId(String id); String getRegion(); void setRegion(String region); String getLocation(); void setLocation(String location); String getState(); void setState(String state); String getToken(); void setToken(String token); Date getCreatedTime(); void setCreatedTime(Date createdTime); String getVpcId(); void setVpcId(String vpcId); String getSubnetId(); void setSubnetId(String subnetId); Map<String, Object> getCloud(); void setCloud(Map<String, Object> cloud); Date getTerminateTime(); void setTerminateTime(Date terminateTime); Date getUpdatedTime(); void setUpdatedTime(Date updatedTime); Date getAwsLaunchTime(); void setAwsLaunchTime(Date awsLaunchTime); AwsStatus getAwsStatus(); void setAwsStatus(AwsStatus awsStatus); }
EsInstance implements EsDocument { public void setState(String state) throws InvalidStateTransitionException { if (StringUtils.isEmpty(this.state)) { this.state = state; } else if (!StringUtils.equals(this.state, state)) { if (STATE_TRANSITION_MAP.containsKey(this.state) && STATE_TRANSITION_MAP.get(this.state) .contains(state)) { this.state = state; } else { throw new InvalidStateTransitionException( String.format("Invalid transit state from %s to %s", this.state, state)); } } }  int getCached(); void setCached(int cached); long getVersion(); void setVersion(long version); List<String> getSecurityGroups(); void setSecurityGroups(List<String> securityGroups); Map<String, String> getTags(); void setTags(Map<String, String> tags); List<String> getSecurityGroupIds(); void setSecurityGroupIds(List<String> securityGroupIds); String getId(); void setId(String id); String getRegion(); void setRegion(String region); String getLocation(); void setLocation(String location); String getState(); void setState(String state); String getToken(); void setToken(String token); Date getCreatedTime(); void setCreatedTime(Date createdTime); String getVpcId(); void setVpcId(String vpcId); String getSubnetId(); void setSubnetId(String subnetId); Map<String, Object> getCloud(); void setCloud(Map<String, Object> cloud); Date getTerminateTime(); void setTerminateTime(Date terminateTime); Date getUpdatedTime(); void setUpdatedTime(Date updatedTime); Date getAwsLaunchTime(); void setAwsLaunchTime(Date awsLaunchTime); AwsStatus getAwsStatus(); void setAwsStatus(AwsStatus awsStatus);  }