刘光辉
6 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 + ")"));
    }
}