|
37 | 37 | import java.io.File; |
38 | 38 | import java.io.FileOutputStream; |
39 | 39 | import java.io.IOException; |
40 | | -import java.io.OutputStream; |
41 | 40 | import java.nio.charset.StandardCharsets; |
42 | 41 | import java.nio.file.Files; |
43 | 42 | import java.nio.file.Path; |
44 | 43 | import java.nio.file.Paths; |
45 | 44 | import java.nio.file.attribute.FileTime; |
46 | | -import java.util.ArrayList; |
47 | | -import java.util.Collections; |
48 | 45 | import java.util.Date; |
49 | 46 | import java.util.Iterator; |
50 | 47 | import java.util.LinkedList; |
51 | 48 | import java.util.List; |
52 | 49 | import java.util.Map; |
53 | 50 | import java.util.Set; |
54 | 51 |
|
55 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
56 | | -import com.fasterxml.jackson.databind.ObjectWriter; |
57 | | -import com.fasterxml.jackson.dataformat.smile.SmileFactory; |
58 | | -import com.fasterxml.jackson.dataformat.smile.SmileParser; |
59 | | -import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper; |
60 | 52 | import org.apache.commons.lang3.time.DateUtils; |
61 | 53 | import org.eclipse.jgit.api.Git; |
62 | 54 | import org.junit.jupiter.api.AfterEach; |
@@ -991,41 +983,4 @@ void testStoreAndTryToGetIgnored() throws Exception { |
991 | 983 | retrievedHistory = cache.get(makefile, repo, true); |
992 | 984 | assertNotNull(retrievedHistory, "history for Makefile should not be null"); |
993 | 985 | } |
994 | | - |
995 | | - // TODO |
996 | | - @Test |
997 | | - void testSmile() throws Exception { |
998 | | - ObjectMapper mapper = new SmileMapper(); |
999 | | - File outputFile = new File("/tmp/histentry"); |
1000 | | - ObjectWriter objectWriter = mapper.writer().forType(HistoryEntry.class); |
1001 | | - |
1002 | | - try (OutputStream outputStream = new FileOutputStream(outputFile)) { |
1003 | | - HistoryEntry historyEntry = new HistoryEntry("1.1.1", "1", |
1004 | | - new Date(1245446973L / 60 * 60 * 1000), |
1005 | | - "xyz", |
1006 | | - "Return failure when executed with no arguments", |
1007 | | - true, Collections.emptyList()); |
1008 | | - byte[] bytes = objectWriter.writeValueAsBytes(historyEntry); |
1009 | | - outputStream.write(bytes); |
1010 | | - |
1011 | | - historyEntry = new HistoryEntry("2.2.2", "2", |
1012 | | - new Date(1245446973L / 60 * 60 * 1000), |
1013 | | - "xyz", |
1014 | | - "Return failure when executed with no arguments", |
1015 | | - true, Collections.emptyList()); |
1016 | | - bytes = objectWriter.writeValueAsBytes(historyEntry); |
1017 | | - outputStream.write(bytes); |
1018 | | - } |
1019 | | - |
1020 | | - SmileFactory factory = new SmileFactory(); |
1021 | | - List<HistoryEntry> historyEntryList = new ArrayList<>(); |
1022 | | - try (SmileParser parser = factory.createParser(outputFile)) { |
1023 | | - parser.setCodec(mapper); |
1024 | | - Iterator<HistoryEntry> historyEntryIterator = parser.readValuesAs(HistoryEntry.class); |
1025 | | - historyEntryIterator.forEachRemaining(historyEntryList::add); |
1026 | | - } |
1027 | | - |
1028 | | - History history = new History(historyEntryList); |
1029 | | - System.out.println(history); |
1030 | | - } |
1031 | 986 | } |
0 commit comments