### Question:
AlgorithmContentEquals { public static boolean contentEquals(Algorithm algo1, Algorithm algo2) { if (algo1.getFileName() != null ? !algo1.getFileName().equals(algo2.getFileName()) : algo2.getFileName() != null) { return false; } if (algo1.getName() != null ? !algo1.getName().equals(algo2.getName()) : algo2.getName() != null) { return false; } if (algo1.getAuthor() != null ? !algo1.getAuthor().equals(algo2.getAuthor()) : algo2.getAuthor() != null) { return false; } if (algo1.getDescription() != null ? !algo1.getDescription().equals(algo2.getDescription()) : algo2.getDescription() != null) { return false; } return AlgorithmType.asStream() .allMatch( type -> algo1.hasAlgorithmType(type) == algo2.hasAlgorithmType(type)); }  static boolean contentEquals(Algorithm algo1, Algorithm algo2);  }### Answer:
@Test public void testContentEquals() { Algorithm algorithm = buildEqualAlgorithm(); Algorithm equalAlgorithm = buildEqualAlgorithm(); Algorithm notEqualAlgorithmFileNameNull = buildEqualAlgorithm(); notEqualAlgorithmFileNameNull.setFileName(null); Algorithm notEqualAlgorithmFileName = buildEqualAlgorithm(); notEqualAlgorithmFileName.setFileName("some other file name"); Algorithm notEqualAlgorithmNameNull = buildEqualAlgorithm(); notEqualAlgorithmNameNull.setName(null); Algorithm notEqualAlgorithmName = buildEqualAlgorithm(); notEqualAlgorithmName.setName("some other name"); Algorithm notEqualAlgorithmAuthorNull = buildEqualAlgorithm(); notEqualAlgorithmAuthorNull.setAuthor(null); Algorithm notEqualAlgorithmAuthor = buildEqualAlgorithm(); notEqualAlgorithmAuthor.setAuthor("some other author"); Algorithm notEqualAlgorithmDescriptionNull = buildEqualAlgorithm(); notEqualAlgorithmDescriptionNull.setDescription(null); Algorithm notEqualAlgorithmDescription = buildEqualAlgorithm(); notEqualAlgorithmDescription.setDescription("some other description"); AlgorithmType.asStream() .forEach( type -> { Algorithm notEqualAlgorithmIsNotType = buildEqualAlgorithm(); notEqualAlgorithmIsNotType.setAlgorithmType(type, false); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmIsNotType)); }); assertTrue(AlgorithmContentEquals.contentEquals(algorithm, equalAlgorithm)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmFileNameNull)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmFileName)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmNameNull)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmName)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmAuthorNull)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmAuthor)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmDescriptionNull)); assertFalse(AlgorithmContentEquals.contentEquals(algorithm, notEqualAlgorithmDescription)); }
@Test public void testContentEqualsLeftNull() { Algorithm algorithm = new Algorithm(null); Algorithm equalAlgorithm = new Algorithm(null); assertTrue(AlgorithmContentEquals.contentEquals(algorithm, equalAlgorithm)); }