package jnpf.limsService.impl;
|
|
import org.junit.Test;
|
|
import java.io.IOException;
|
import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
import java.nio.file.Paths;
|
|
import static org.junit.Assert.assertTrue;
|
|
public class LimsTestWorkItemSnapshotSourceContractTest {
|
|
@Test
|
public void normalAndWaterCreationPathsFreezeBasisOnTheTestWorkItem() throws IOException {
|
String source = new String(Files.readAllBytes(Paths.get(
|
"src/main/java/jnpf/limsService/impl/LimsQingyandanServiceImpl.java")),
|
StandardCharsets.UTF_8);
|
|
assertMethodCopiesBasis(source, "private LimsJianyanXiangEntity buildXiangFromQingyandan",
|
"zixiang.getBiaozhunGuiding()");
|
assertMethodCopiesBasis(source, "private LimsJianyanXiangEntity buildXiangFromRenwuKuaizhao",
|
"kuaizhao.getBiaozhunGuiding()");
|
}
|
|
private static void assertMethodCopiesBasis(String source, String method, String origin) {
|
int start = source.indexOf(method);
|
int end = source.indexOf("\n private ", start + method.length());
|
String body = source.substring(start, end < 0 ? source.length() : end);
|
assertTrue(method + " must freeze test.basis on the task row",
|
body.contains("record.setBiaozhunGuiding(" + origin + ")"));
|
}
|
}
|