ConvertRecord { public static Map<String, Set<String>> convertCustomProperties(List<CSVRecord> records){ Map<String, Set<String>> resultProperties = new HashMap<>(); for (CSVRecord record : records){ if(! isValidPropertyRecord(record)){ break; } String property = record.get(1).trim(); String value = record.get(2).trim(); addPropertyAndValueToMap(property, value, resultProperties); } return resultProperties; } private  ConvertRecord(); static List<RiskCategory> convertRiskCategories(List<CSVRecord> records); static Serializer<RiskCategory> riskCategorySerializer(); static List<Risk> convertRisks(List<CSVRecord> records, Map<Integer, RiskCategory> categories); static Serializer<Risk> riskSerializer(); static Map<String, Set<String>> convertCustomProperties(List<CSVRecord> records); static Map<Integer, PropertyWithValue> convertCustomPropertiesById(List<CSVRecord> records); static void fillTodoCustomPropertyInfo(List<Todo> todos, List<PropertyWithValueAndId> customProperties, SetMultimap<Integer, Integer> todoCustomPropertyMap); static Serializer<PropertyWithValueAndId> customPropertiesSerializer(); static List<Todo> convertTodos(List<CSVRecord> records); static Serializer<Todo> todoSerializer(); static List<Obligation> convertObligation(List<CSVRecord> records); static Serializer<Obligation> obligationSerializer(); static void putToTodos(Map<Integer, Obligation> obligations, Map<Integer, Todo> todos, Map<Integer, Set<Integer>> obligationTodo); static List<LicenseType> convertLicenseTypes(List<CSVRecord> records); static Serializer<LicenseType> licenseTypeSerializer(); static List<License> fillLicenses(List<CSVRecord> records, Map<Integer, LicenseType> licenseTypeMap, Map<Integer, Todo> todoMap, Map<Integer, Risk> riskMap, Map<String, Set<Integer>> licenseTodo, Map<String, Set<Integer>> licenseRisk); static Serializer<License> licenseSerializer(); static Map<String, Set<Integer>> convertRelationalTable(List<CSVRecord> records); static Map<Integer, Set<Integer>> convertRelationalTableWithIntegerKeys(List<CSVRecord> records); @NotNull static SetMultimap<Integer, Integer> getTodoToObligationMap(List<Todo> todos); @NotNull static SetMultimap<String, Integer> getLicenseToTodoMap(List<License> licenses); @NotNull static SetMultimap<String, Integer> getLicenseToRiskMap(List<License> licenses); static void addLicenses(LicenseService.Iface licenseClient, List<License> licensesToAdd, Logger log, User user); static List<List<String>> serialize(List<T> in, Serializer<T> serializer); static List<List<String>> serialize(List<T> in, List<String> headers, Function<T, List<String>> function); @NotNull static List<List<String>> serialize(SetMultimap<T, U> aToB, List<String> headers); static Gson gson; }
@Test public void testConvertCustomPropertiesEmpty() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(emptyRecord); assertThat(properties.keySet().size(), is(0)); assertThat(properties.values().size(), is(0)); }
@Test public void testConvertCustomPropertiesEmptyProp() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(emptyPropRecord); assertThat(properties.keySet().size(), is(0)); assertThat(properties.values().size(), is(0)); }
@Test public void testConvertCustomPropertiesWhitespaceProp() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(whitePropRecord); assertThat(properties.keySet().size(), is(0)); assertThat(properties.values().size(), is(0)); }
@Test public void testConvertCustomPropertiesEmptyValue() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(emptyValRecord); assertThat(properties.keySet().size(), is(1)); assertThat(properties.values().size(), is(1)); }
@Test public void testConvertCustomPropertiesWhiteValue() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(whiteValRecord); assertThat(properties.keySet().size(), is(1)); assertThat(properties.values().size(), is(1)); }
@Test public void testConvertCustomPropertiesTooSmall() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(tooSmallRecord); assertThat(properties.keySet().size(), is(0)); assertThat(properties.values().size(), is(0)); }
@Test public void testConvertCustomPropertiesSmallestPossible() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(smallestPossibleRecord); assertThat(properties.keySet(), Matchers.containsInAnyOrder("prop1")); assertThat(properties.get("prop1"), Matchers.containsInAnyOrder("val1")); }
@Test public void testConvertCustomPropertiesFull() throws Exception { Map<String, Set<String>> properties = convertCustomProperties(fullRecord); assertThat(properties.keySet(), Matchers.containsInAnyOrder("A", "B")); assertThat(properties.get("A"), Matchers.containsInAnyOrder("A1", "A2", "A3")); assertThat(properties.get("B"), Matchers.containsInAnyOrder("B1", "B2")); }