@Test public void testSetPrivateData() { PrivateDataInfo phoneNumber = new PrivateDataInfo(); phoneNumber.setCategory("KEYWORD"); phoneNumber.setType("Phone Number"); phoneNumber.setValue("123-123-1234"); phoneNumber.setSelected(true); PrivateDataInfo somePattern = new PrivateDataInfo(); somePattern.setCategory("PATTERN"); somePattern.setType("PATTERNNAME"); somePattern.setValue("PATTERNVALUE"); somePattern.setSelected(false); List<PrivateDataInfo> privateData = new ArrayList<PrivateDataInfo>(); privateData.add(phoneNumber); privateData.add(somePattern); UserPreferences userPrefs = MockUserPreferencesFactory.getInstance().create(); userPrefs.setPrivateData(privateData); IPreferenceHandler mockPrefHandler = userPrefs.getPreferenceHandler(); String actualPrivateDataPersisted = mockPrefHandler.getPref(PRIVATE_DATA); String expectedPrivateDataPersisted = "KEYWORD,Phone Number,123-123-1234,Y;PATTERN,PATTERNNAME,PATTERNVALUE,N"; assertEquals(expectedPrivateDataPersisted, actualPrivateDataPersisted); }
public void setPrivateData(List<PrivateDataInfo> privateData) { if (privateData == null) { throw new IllegalArgumentException("Private data must be non-null."); } StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < privateData.size(); i++) { strBuilder.append(privateData.get(i).getCategory()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getType()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getValue()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).isSelected()? TraceDataConst.PrivateData.YES_SELECTED : TraceDataConst.PrivateData.NO_SELECTED); if (i < privateData.size() - 1) { strBuilder.append(TraceDataConst.PrivateData.ITEM_DELIMITER); } } prefHandler.setPref(PRIVATE_DATA, strBuilder.toString()); }
UserPreferences { public void setPrivateData(List<PrivateDataInfo> privateData) { if (privateData == null) { throw new IllegalArgumentException("Private data must be non-null."); } StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < privateData.size(); i++) { strBuilder.append(privateData.get(i).getCategory()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getType()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getValue()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).isSelected()? TraceDataConst.PrivateData.YES_SELECTED : TraceDataConst.PrivateData.NO_SELECTED); if (i < privateData.size() - 1) { strBuilder.append(TraceDataConst.PrivateData.ITEM_DELIMITER); } } prefHandler.setPref(PRIVATE_DATA, strBuilder.toString()); } }
UserPreferences { public void setPrivateData(List<PrivateDataInfo> privateData) { if (privateData == null) { throw new IllegalArgumentException("Private data must be non-null."); } StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < privateData.size(); i++) { strBuilder.append(privateData.get(i).getCategory()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getType()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getValue()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).isSelected()? TraceDataConst.PrivateData.YES_SELECTED : TraceDataConst.PrivateData.NO_SELECTED); if (i < privateData.size() - 1) { strBuilder.append(TraceDataConst.PrivateData.ITEM_DELIMITER); } } prefHandler.setPref(PRIVATE_DATA, strBuilder.toString()); } private  UserPreferences(); }
UserPreferences { public void setPrivateData(List<PrivateDataInfo> privateData) { if (privateData == null) { throw new IllegalArgumentException("Private data must be non-null."); } StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < privateData.size(); i++) { strBuilder.append(privateData.get(i).getCategory()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getType()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getValue()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).isSelected()? TraceDataConst.PrivateData.YES_SELECTED : TraceDataConst.PrivateData.NO_SELECTED); if (i < privateData.size() - 1) { strBuilder.append(TraceDataConst.PrivateData.ITEM_DELIMITER); } } prefHandler.setPref(PRIVATE_DATA, strBuilder.toString()); } private  UserPreferences(); File getLastTraceDirectory(); void setLastTraceDirectory(File tdPath); String getLastProfile(); String getLastProfile(ProfileType profileType); void setLastProfile(Profile profile); File getLastProfileDirectory(); void setLastProfileDirectory(File profilePath); File getLastExportDirectory(); void setLastExportDirectory(File exportDir); List<PrivateDataInfo> getPrivateData(); void setPrivateData(List<PrivateDataInfo> privateData); }
UserPreferences { public void setPrivateData(List<PrivateDataInfo> privateData) { if (privateData == null) { throw new IllegalArgumentException("Private data must be non-null."); } StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < privateData.size(); i++) { strBuilder.append(privateData.get(i).getCategory()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getType()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).getValue()); strBuilder.append(TraceDataConst.PrivateData.COLUMN_DELIMITER); strBuilder.append(privateData.get(i).isSelected()? TraceDataConst.PrivateData.YES_SELECTED : TraceDataConst.PrivateData.NO_SELECTED); if (i < privateData.size() - 1) { strBuilder.append(TraceDataConst.PrivateData.ITEM_DELIMITER); } } prefHandler.setPref(PRIVATE_DATA, strBuilder.toString()); } private  UserPreferences(); File getLastTraceDirectory(); void setLastTraceDirectory(File tdPath); String getLastProfile(); String getLastProfile(ProfileType profileType); void setLastProfile(Profile profile); File getLastProfileDirectory(); void setLastProfileDirectory(File profilePath); File getLastExportDirectory(); void setLastExportDirectory(File exportDir); List<PrivateDataInfo> getPrivateData(); void setPrivateData(List<PrivateDataInfo> privateData);  }