String componentKey = componentEntry.getKey();
Snapshot snapshot = componentEntry.getValue();
for (Cache.Entry<Data> dataEntry : data.entries(componentKey)) {
- if (dataEntry.value() != null) {
+ Data value = dataEntry.value();
+ if (value != null) {
SnapshotDataDto dto = new SnapshotDataDto();
dto.setSnapshotId(snapshot.getId());
dto.setResourceId(snapshot.getResourceId());
dto.setDataType(dataEntry.key());
- dto.setData(dataEntry.value().writeString());
+ dto.setData(value.writeString());
dao.insert(session, dto);
}
}
}
public List<Transition> outTransitions(Issue issue) {
- return machine.state(issue.status()).outManualTransitions(issue);
+ State state = machine.state(issue.status());
+ if (state == null) {
+ throw new IllegalArgumentException("Unknown status: " + issue.status());
+ }
+ return state.outManualTransitions(issue);
}
public void doAutomaticTransition(DefaultIssue issue, IssueChangeContext issueChangeContext) {
import org.sonar.api.issue.Issue;
import javax.annotation.CheckForNull;
-
import java.util.List;
import java.util.Set;
assertThat(keys(transitions)).containsOnly("confirm", "resolve", "falsepositive");
}
+ @Test
+ public void should_fail_if_unknown_status_when_listing_transitions() throws Exception {
+ workflow.start();
+
+ DefaultIssue issue = new DefaultIssue().setStatus("xxx");
+ try {
+ workflow.outTransitions(issue);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertThat(e).hasMessage("Unknown status: xxx");
+ }
+ }
+
+
@Test
public void should_do_automatic_transition() throws Exception {
workflow.start();
@Test
- public void should_fail_if_unknown_status() throws Exception {
+ public void should_fail_if_unknown_status_on_automatic_trans() throws Exception {
workflow.start();
DefaultIssue issue = new DefaultIssue()