feat: validate feature conversion rice scoring
parent
766dde4d73
commit
f5c61f8035
@ -0,0 +1,52 @@
|
||||
package com.sztzjy.linkCommerce.entity.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FeatureConversionStepTwoValidationRequest {
|
||||
private List<String> sourceDefinitions;
|
||||
private List<RiceScoreRow> rows;
|
||||
|
||||
public List<String> getSourceDefinitions() {
|
||||
return sourceDefinitions;
|
||||
}
|
||||
|
||||
public void setSourceDefinitions(List<String> sourceDefinitions) {
|
||||
this.sourceDefinitions = sourceDefinitions;
|
||||
}
|
||||
|
||||
public List<RiceScoreRow> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(List<RiceScoreRow> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public static class RiceScoreRow {
|
||||
private String requirementId;
|
||||
private String name;
|
||||
private String kano;
|
||||
private Double reach;
|
||||
private Double impact;
|
||||
private Double confidence;
|
||||
private Double effort;
|
||||
private String riceScore;
|
||||
|
||||
public String getRequirementId() { return requirementId; }
|
||||
public void setRequirementId(String requirementId) { this.requirementId = requirementId; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getKano() { return kano; }
|
||||
public void setKano(String kano) { this.kano = kano; }
|
||||
public Double getReach() { return reach; }
|
||||
public void setReach(Double reach) { this.reach = reach; }
|
||||
public Double getImpact() { return impact; }
|
||||
public void setImpact(Double impact) { this.impact = impact; }
|
||||
public Double getConfidence() { return confidence; }
|
||||
public void setConfidence(Double confidence) { this.confidence = confidence; }
|
||||
public Double getEffort() { return effort; }
|
||||
public void setEffort(Double effort) { this.effort = effort; }
|
||||
public String getRiceScore() { return riceScore; }
|
||||
public void setRiceScore(String riceScore) { this.riceScore = riceScore; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.sztzjy.linkCommerce.entity.dto;
|
||||
|
||||
public class FeatureConversionStepTwoValidationResult {
|
||||
private boolean valid;
|
||||
private String message;
|
||||
|
||||
public boolean isValid() { return valid; }
|
||||
public void setValid(boolean valid) { this.valid = valid; }
|
||||
public String getMessage() { return message; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.sztzjy.linkCommerce.service;
|
||||
|
||||
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||||
import com.sztzjy.linkCommerce.entity.dto.FeatureConversionStepTwoValidationRequest;
|
||||
import com.sztzjy.linkCommerce.entity.dto.FeatureConversionStepTwoValidationResult;
|
||||
|
||||
public interface FeatureConversionStepTwoService {
|
||||
FeatureConversionStepTwoValidationResult validate(FeatureConversionStepTwoValidationRequest request, JwtUser user);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.sztzjy.linkCommerce.service.impl;
|
||||
|
||||
import com.sztzjy.linkCommerce.config.exception.handler.ServiceException;
|
||||
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||||
import com.sztzjy.linkCommerce.entity.dto.FeatureConversionStepTwoValidationRequest;
|
||||
import com.sztzjy.linkCommerce.entity.dto.FeatureConversionStepTwoValidationResult;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class FeatureConversionStepTwoServiceImplTest {
|
||||
private final FeatureConversionStepTwoServiceImpl service = new FeatureConversionStepTwoServiceImpl();
|
||||
|
||||
@Test
|
||||
void acceptsSynchronizedRiceRows() {
|
||||
FeatureConversionStepTwoValidationResult result = service.validate(request(), student());
|
||||
|
||||
assertTrue(result.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsNameNotSynchronizedWithStepOne() {
|
||||
FeatureConversionStepTwoValidationRequest request = request();
|
||||
request.getRows().get(0).setName("手动修改的功能");
|
||||
|
||||
assertThrows(ServiceException.class, () -> service.validate(request, student()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInvalidRiceScore() {
|
||||
FeatureConversionStepTwoValidationRequest request = request();
|
||||
request.getRows().get(0).setRiceScore("15.99");
|
||||
|
||||
assertThrows(ServiceException.class, () -> service.validate(request, student()));
|
||||
}
|
||||
|
||||
private FeatureConversionStepTwoValidationRequest request() {
|
||||
FeatureConversionStepTwoValidationRequest request = new FeatureConversionStepTwoValidationRequest();
|
||||
List<String> definitions = new ArrayList<>();
|
||||
List<FeatureConversionStepTwoValidationRequest.RiceScoreRow> rows = new ArrayList<>();
|
||||
for (int index = 0; index < 8; index++) {
|
||||
String definition = "功能定义" + (index + 1);
|
||||
definitions.add(definition);
|
||||
FeatureConversionStepTwoValidationRequest.RiceScoreRow row = new FeatureConversionStepTwoValidationRequest.RiceScoreRow();
|
||||
row.setRequirementId(String.format("F%02d", index + 1));
|
||||
row.setName(definition);
|
||||
row.setKano("基本型");
|
||||
row.setReach(5D);
|
||||
row.setImpact(4D);
|
||||
row.setConfidence(80D);
|
||||
row.setEffort(1D);
|
||||
row.setRiceScore("16.00");
|
||||
rows.add(row);
|
||||
}
|
||||
request.setSourceDefinitions(definitions);
|
||||
request.setRows(rows);
|
||||
return request;
|
||||
}
|
||||
|
||||
private JwtUser student() {
|
||||
JwtUser user = new JwtUser();
|
||||
user.setUserId("stu-1");
|
||||
user.setRoleId(4);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue