This commit is contained in:
Greg DiCristofaro 2022-02-22 21:00:05 -05:00
parent 316b214924
commit c06184ee7c
17 changed files with 68 additions and 76 deletions

View File

@ -111,7 +111,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex); logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, "Unable to retrieve data from the Central Repository: ", ex.getMessage()); logger.log(Level.WARNING, "Unable to retrieve data from the Central Repository.", ex);
} }
} }

View File

@ -139,7 +139,7 @@ public final class OtherOccurrences {
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, "Error getting artifact instances from database.", ex); // NON-NLS logger.log(Level.SEVERE, "Error getting artifact instances from database.", ex); // NON-NLS
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.INFO, "Error getting artifact instances from database: " + ex.getMessage()); // NON-NLS logger.log(Level.INFO, "Error getting artifact instances from database.", ex); // NON-NLS
} catch (NoCurrentCaseException ex) { } catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS logger.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
} }

View File

@ -196,7 +196,7 @@ public final class OtherOccurrencesPanel extends javax.swing.JPanel {
eamArtifact.getCorrelationType().getDisplayName(), eamArtifact.getCorrelationType().getDisplayName(),
eamArtifact.getCorrelationValue())); eamArtifact.getCorrelationValue()));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, String.format("Error getting commonality details for artifact with ID: %s: %s", eamArtifact.getID(), ex.getMessage())); logger.log(Level.WARNING, String.format("Error getting commonality details for artifact with ID: %s.", eamArtifact.getID()), ex);
} }
} }
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

View File

@ -114,7 +114,7 @@ public class CentralRepoFileInstance {
/** /**
* @param MD5Hash the MD5Hash to set * @param MD5Hash the MD5Hash to set
*/ */
public void setMD5Hash(String MD5Hash) throws CorrelationAttributeNormalizationException { public void setMD5Hash(String MD5Hash) throws CorrelationAttributeNormalizationException, CentralRepoException {
this.MD5Hash = CorrelationAttributeNormalizer.normalize(CorrelationAttributeInstance.FILES_TYPE_ID, MD5Hash); this.MD5Hash = CorrelationAttributeNormalizer.normalize(CorrelationAttributeInstance.FILES_TYPE_ID, MD5Hash);
} }

View File

@ -47,13 +47,13 @@ final public class CorrelationAttributeNormalizer {
* *
* @return normalized data * @return normalized data
*/ */
public static String normalize(CorrelationAttributeInstance.Type attributeType, String data) throws CorrelationAttributeNormalizationException { public static String normalize(CorrelationAttributeInstance.Type attributeType, String data) throws CorrelationAttributeNormalizationException, CentralRepoException {
if (attributeType == null) { if (attributeType == null) {
throw new CorrelationAttributeNormalizationException("Attribute type was null."); throw new CentralRepoException("Attribute type was null.");
} }
if (data == null) { if (data == null) {
throw new CorrelationAttributeNormalizationException("Correlation value was null."); throw new CentralRepoException("Correlation value was null.");
} }
String trimmedData = data.trim(); String trimmedData = data.trim();
@ -81,7 +81,6 @@ final public class CorrelationAttributeNormalizer {
return normalizeIccid(trimmedData); return normalizeIccid(trimmedData);
default: default:
try {
// If the atttribute is not one of the above // If the atttribute is not one of the above
// but is one of the other default correlation types, then let the data go as is // but is one of the other default correlation types, then let the data go as is
List<CorrelationAttributeInstance.Type> defaultCorrelationTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes(); List<CorrelationAttributeInstance.Type> defaultCorrelationTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes();
@ -93,10 +92,7 @@ final public class CorrelationAttributeNormalizer {
final String errorMessage = String.format( final String errorMessage = String.format(
"Validator function not found for attribute type: %s", "Validator function not found for attribute type: %s",
attributeType.getDisplayName()); attributeType.getDisplayName());
throw new CorrelationAttributeNormalizationException(errorMessage); throw new CentralRepoException(errorMessage);
} catch (CentralRepoException ex) {
throw new CorrelationAttributeNormalizationException("Failed to get default correlation types.", ex);
}
} }
} }
@ -109,8 +105,7 @@ final public class CorrelationAttributeNormalizer {
* *
* @return normalized data * @return normalized data
*/ */
public static String normalize(int attributeTypeId, String data) throws CorrelationAttributeNormalizationException { public static String normalize(int attributeTypeId, String data) throws CorrelationAttributeNormalizationException, CentralRepoException {
try {
List<CorrelationAttributeInstance.Type> defaultTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes(); List<CorrelationAttributeInstance.Type> defaultTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes();
Optional<CorrelationAttributeInstance.Type> typeOption = defaultTypes.stream().filter(attributeType -> attributeType.getId() == attributeTypeId).findAny(); Optional<CorrelationAttributeInstance.Type> typeOption = defaultTypes.stream().filter(attributeType -> attributeType.getId() == attributeTypeId).findAny();
@ -120,9 +115,6 @@ final public class CorrelationAttributeNormalizer {
} else { } else {
throw new CorrelationAttributeNormalizationException(String.format("Given attributeTypeId did not correspond to any known Attribute: %s", attributeTypeId)); throw new CorrelationAttributeNormalizationException(String.format("Given attributeTypeId did not correspond to any known Attribute: %s", attributeTypeId));
} }
} catch (CentralRepoException ex) {
throw new CorrelationAttributeNormalizationException(ex);
}
} }
/** /**

View File

@ -1276,7 +1276,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
@Override @Override
public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException {
if (value == null) { if (value == null) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null value"); throw new CentralRepoException("Cannot get artifact instances for null value");
} }
return getArtifactInstancesByTypeValues(aType, Arrays.asList(value)); return getArtifactInstancesByTypeValues(aType, Arrays.asList(value));
} }
@ -1284,10 +1284,10 @@ abstract class RdbmsCentralRepo implements CentralRepository {
@Override @Override
public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List<String> values) throws CentralRepoException, CorrelationAttributeNormalizationException { public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List<String> values) throws CentralRepoException, CorrelationAttributeNormalizationException {
if (aType == null) { if (aType == null) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null type"); throw new CentralRepoException("Cannot get artifact instances for null type");
} }
if (values == null || values.isEmpty()) { if (values == null || values.isEmpty()) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances without specified values"); throw new CentralRepoException("Cannot get artifact instances without specified values");
} }
return getCorrAttrInstances(prepareGetInstancesSql(aType, values), aType); return getCorrAttrInstances(prepareGetInstancesSql(aType, values), aType);
} }
@ -1295,13 +1295,13 @@ abstract class RdbmsCentralRepo implements CentralRepository {
@Override @Override
public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List<String> values, List<Integer> caseIds) throws CentralRepoException, CorrelationAttributeNormalizationException { public List<CorrelationAttributeInstance> getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List<String> values, List<Integer> caseIds) throws CentralRepoException, CorrelationAttributeNormalizationException {
if (aType == null) { if (aType == null) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null type"); throw new CentralRepoException("Cannot get artifact instances for null type");
} }
if (values == null || values.isEmpty()) { if (values == null || values.isEmpty()) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances without specified values"); throw new CentralRepoException("Cannot get artifact instances without specified values");
} }
if (caseIds == null || caseIds.isEmpty()) { if (caseIds == null || caseIds.isEmpty()) {
throw new CorrelationAttributeNormalizationException("Cannot get artifact instances without specified cases"); throw new CentralRepoException("Cannot get artifact instances without specified cases");
} }
String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType);
String sql String sql
@ -1327,7 +1327,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
* *
* @throws CorrelationAttributeNormalizationException * @throws CorrelationAttributeNormalizationException
*/ */
private String prepareGetInstancesSql(CorrelationAttributeInstance.Type aType, List<String> values) throws CorrelationAttributeNormalizationException { private String prepareGetInstancesSql(CorrelationAttributeInstance.Type aType, List<String> values) throws CorrelationAttributeNormalizationException, CentralRepoException {
String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType);
String sql String sql
= "SELECT " = "SELECT "

View File

@ -81,7 +81,7 @@ class CentralRepoIngestModuleUtils {
} }
} }
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.WARNING, String.format("Error normalizing correlation attribute value for 's' (job ID=%d): %s", corrAttr, ingestJobId, ex.getMessage())); // NON-NLS LOGGER.log(Level.WARNING, String.format("Error normalizing correlation attribute value for 's' (job ID=%d)", corrAttr, ingestJobId), ex); // NON-NLS
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
LOGGER.log(Level.SEVERE, String.format("Error getting previous occurences of correlation attribute 's' (job ID=%d)", corrAttr, ingestJobId), ex); // NON-NLS LOGGER.log(Level.SEVERE, String.format("Error getting previous occurences of correlation attribute 's' (job ID=%d)", corrAttr, ingestJobId), ex); // NON-NLS
} }

View File

@ -240,7 +240,7 @@ final public class CommonAttributeCaseSearchResults {
return true; return true;
} }
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.WARNING, "Unable to determine frequency percentage attribute - frequency filter may not be accurate for these results: " + ex.getMessage()); LOGGER.log(Level.WARNING, "Unable to determine frequency percentage attribute - frequency filter may not be accurate for these results.", ex);
} }
} }
return false; return false;

View File

@ -162,7 +162,7 @@ final public class CommonAttributeCountSearchResults {
} }
} }
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.WARNING, "Unable to determine frequency percentage attribute - frequency filter may not be accurate for these results: " + ex.getMessage()); LOGGER.log(Level.WARNING, "Unable to determine frequency percentage attribute - frequency filter may not be accurate for these results.", ex);
} }
} }
} }

View File

@ -308,7 +308,7 @@ final class InterCaseSearchResultsProcessor {
} }
} }
} catch (SQLException | CentralRepoException | CorrelationAttributeNormalizationException ex) { } catch (SQLException | CentralRepoException | CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.WARNING, "Error getting artifact instances from database: " + ex.getMessage()); // NON-NLS LOGGER.log(Level.WARNING, "Error getting artifact instances from database.", ex); // NON-NLS
} }
} }
@ -386,7 +386,7 @@ final class InterCaseSearchResultsProcessor {
} }
} }
} catch (CentralRepoException | SQLException | CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | SQLException | CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.WARNING, "Error getting artifact instances from database: " + ex.getMessage()); // NON-NLS LOGGER.log(Level.WARNING, "Error getting artifact instances from database.", ex); // NON-NLS
} }
} }
@ -424,7 +424,7 @@ final class InterCaseSearchResultsProcessor {
InstanceTableCallback.getFilePath(resultSet)); InstanceTableCallback.getFilePath(resultSet));
} }
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
LOGGER.log(Level.INFO, "Unable to get CorrelationAttributeInstance: " + ex.getMessage()); // NON-NLS LOGGER.log(Level.INFO, "Unable to get CorrelationAttributeInstance.", ex); // NON-NLS
} }
} }

View File

@ -90,7 +90,7 @@ final class CorrelationCaseChildNodeFactory extends ChildFactory<CorrelationCase
}); });
} }
} catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, String.format("Unable to getArtifactInstance for accountID, %d: %s", account.getAccountID(), ex.getMessage())); //NON-NLS logger.log(Level.WARNING, String.format("Unable to getArtifactInstance for accountID: %d", account.getAccountID()), ex); //NON-NLS
} }
}); });

View File

@ -489,7 +489,7 @@ public class AnnotationUtils {
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, "Error connecting to the Central Repository database.", ex); // NON-NLS logger.log(Level.SEVERE, "Error connecting to the Central Repository database.", ex); // NON-NLS
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, "Error normalizing instance from Central Repository database: " + ex.getMessage()); // NON-NLS logger.log(Level.WARNING, "Error normalizing instance from Central Repository database.", ex); // NON-NLS
} }
return instancesToRet; return instancesToRet;

View File

@ -449,7 +449,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, "Error getting count of datasources with correlation attribute", ex); logger.log(Level.SEVERE, "Error getting count of datasources with correlation attribute", ex);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, "Unable to normalize data to get count of datasources with correlation attribute: " + ex.getMessage()); logger.log(Level.WARNING, "Unable to normalize data to get count of datasources with correlation attribute", ex);
} }
return Pair.of(count, description); return Pair.of(count, description);
} }

View File

@ -1232,7 +1232,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex); logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3} message={4})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue(), ex.getMessage())); logger.log(Level.WARNING, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex);
} }
return Pair.of(count, description); return Pair.of(count, description);
} }

View File

@ -535,7 +535,7 @@ public final class OsAccounts implements AutopsyVisitableItem {
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
logger.log(Level.SEVERE, String.format("Error getting count of data sources with %s correlation attribute %s", attributeInstance.getCorrelationType().getDisplayName(), attributeInstance.getCorrelationValue()), ex); logger.log(Level.SEVERE, String.format("Error getting count of data sources with %s correlation attribute %s", attributeInstance.getCorrelationType().getDisplayName(), attributeInstance.getCorrelationValue()), ex);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.WARNING, String.format("Unable to normalize %s correlation attribute %s: %s", attributeInstance.getCorrelationType().getDisplayName(), attributeInstance.getCorrelationValue(), ex.getMessage())); logger.log(Level.WARNING, String.format("Unable to normalize %s correlation attribute %s", attributeInstance.getCorrelationType().getDisplayName(), attributeInstance.getCorrelationValue()), ex);
} }
return Pair.of(count, description); return Pair.of(count, description);
} }

View File

@ -327,7 +327,7 @@ public class DiscoveryAttributes {
if (context.searchIsCancelled()) { if (context.searchIsCancelled()) {
throw new SearchCancellationException("Search was cancelled while orgainizing domains by their normalized value."); throw new SearchCancellationException("Search was cancelled while orgainizing domains by their normalized value.");
} }
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
logger.log(Level.INFO, String.format("Domain [%s] failed normalization, skipping...", domainInstance.getDomain())); logger.log(Level.INFO, String.format("Domain [%s] failed normalization, skipping...", domainInstance.getDomain()));
} }
} }

View File

@ -54,32 +54,32 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
try { try {
assertTrue("This hash should just work", CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, aValidHash).equals(aValidHash)); assertTrue("This hash should just work", CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, aValidHash).equals(aValidHash));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue("This hash just needs to be converted to lower case", CorrelationAttributeNormalizer.normalize(CorrelationAttributeInstance.FILES_TYPE_ID, aValidHashWithCaps).equals(aValidHash)); assertTrue("This hash just needs to be converted to lower case", CorrelationAttributeNormalizer.normalize(CorrelationAttributeInstance.FILES_TYPE_ID, aValidHashWithCaps).equals(aValidHash));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, anInValidHash); CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, anInValidHash);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, emptyHash); CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, emptyHash);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, nullHash); CorrelationAttributeNormalizer.normalize(FILES_TYPE_ID, nullHash);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
} }
@ -149,7 +149,7 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
String normalizedDomain = CorrelationAttributeNormalizer.normalize(DOMAIN_TYPE_ID, input); String normalizedDomain = CorrelationAttributeNormalizer.normalize(DOMAIN_TYPE_ID, input);
assertTrue(String.format("Expected domain '%s' to be normalized, but was null.", item.getOriginalString()), normalizedDomain != null); assertTrue(String.format("Expected domain '%s' to be normalized, but was null.", item.getOriginalString()), normalizedDomain != null);
assertTrue(String.format("Was unable to normalize domain '%s' to '%s' but received %s instead.", input, expected, normalizedDomain), normalizedDomain.equals(expected)); assertTrue(String.format("Was unable to normalize domain '%s' to '%s' but received %s instead.", input, expected, normalizedDomain), normalizedDomain.equals(expected));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(String.format("Unable to properly parse %s to %s. Received: %s", input, expected, ex.getMessage())); fail(String.format("Unable to properly parse %s to %s. Received: %s", input, expected, ex.getMessage()));
} }
@ -158,7 +158,7 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
try { try {
CorrelationAttributeNormalizer.normalize(DOMAIN_TYPE_ID, item.getOriginalString()); CorrelationAttributeNormalizer.normalize(DOMAIN_TYPE_ID, item.getOriginalString());
fail(String.format("Original string: '%s' should have failed to parse.", item.getOriginalString())); fail(String.format("Original string: '%s' should have failed to parse.", item.getOriginalString()));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
} }
@ -178,43 +178,43 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
try { try {
assertTrue("This email should pass.", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailOne).equals(goodEmailOne)); assertTrue("This email should pass.", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailOne).equals(goodEmailOne));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue("This email should pass.", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailTwo).equals(goodEmailTwo.toLowerCase())); assertTrue("This email should pass.", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailTwo).equals(goodEmailTwo.toLowerCase()));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailThree); CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailThree);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailFour); CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailFour);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailFive); CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailFive);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { //TODO consider a better library? try { //TODO consider a better library?
assertTrue("This email should pass", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailSix).equals(goodEmailSix)); assertTrue("This email should pass", CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, goodEmailSix).equals(goodEmailSix));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailSeven); CorrelationAttributeNormalizer.normalize(EMAIL_TYPE_ID, badEmailSeven);
fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION); fail(THIS_SHOULD_HAVE_THROWN_AN_EXCEPTION);
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
} }
@ -234,56 +234,56 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnOne).equals(goodPnOne)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnOne).equals(goodPnOne));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnTwo).equals(goodPnOne)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnTwo).equals(goodPnOne));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnThree).equals(goodPnThree)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnThree).equals(goodPnThree));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnFour).equals(goodPnOne)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnFour).equals(goodPnOne));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnFive); CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnFive);
//fail("This should have thrown an exception."); //this will eventually pass when we do a better job at this //fail("This should have thrown an exception."); //this will eventually pass when we do a better job at this
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnSix).equals(goodPnThree)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnSix).equals(goodPnThree));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnSeven).equals(goodPnThree)); assertTrue(THIS_PHONE_NUMBER_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, goodPnSeven).equals(goodPnThree));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
fail(ex.getMessage()); fail(ex.getMessage());
} }
try { try {
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnEight); CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnEight);
fail("This should have thrown an exception."); fail("This should have thrown an exception.");
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
try { try {
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnNine); CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnNine);
fail("This should have thrown an exception."); fail("This should have thrown an exception.");
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true); assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
} }
} }
@ -304,7 +304,7 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
try { try {
assertTrue(THIS_USB_ID_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(USBID_TYPE_ID, goodIdOne).equals(goodIdOne)); assertTrue(THIS_USB_ID_SHOULD_PASS, CorrelationAttributeNormalizer.normalize(USBID_TYPE_ID, goodIdOne).equals(goodIdOne));
} catch (CorrelationAttributeNormalizationException ex) { } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) {
Assert.fail(ex.getMessage()); Assert.fail(ex.getMessage());
} }
} }