@Test public void testEqualsAndHashcode() { PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new FileSystemResourceProvider(), new FileSystemResourceProvider()); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new FileSystemResourceProvider("src/test/resources"), new FileSystemResourceProvider("src/test/resources")); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new FileSystemResourceProvider("src/test/resources"), new FileSystemResourceProvider(new File("src/test/resources"))); }
@Test public void testAll() { FormattedObject aFO = new FormattedObject("Any", new BracketFormatter()); assertEquals("Any", aFO.getValue()); assertEquals(BracketFormatter.class, aFO.getFormatter().getClass()); assertEquals("[Any]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new BracketFormatter(new BracketFormatter())); assertEquals("Any", aFO.getValue()); assertEquals(BracketFormatter.class, aFO.getFormatter().getClass()); assertEquals("[[Any]]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject( "Any", new IFormatterProvider() { public IFormatter getFormatter() { return new BracketFormatter(); } }); assertEquals("Any", aFO.getValue()); assertEquals(BracketFormatter.class, aFO.getFormatter().getClass()); assertEquals("[Any]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject(null, new BracketFormatter(new BracketFormatter())); assertNull(aFO.getValue()); assertEquals(BracketFormatter.class, aFO.getFormatter().getClass()); assertEquals("[[]]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new StringPrefixFormatter("x ")); assertEquals("Any", aFO.getValue()); assertEquals(StringPrefixFormatter.class, aFO.getFormatter().getClass()); assertEquals("x Any", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new StringPrefixFormatter(new BracketFormatter(), "x ")); assertEquals("Any", aFO.getValue()); assertEquals(StringPrefixFormatter.class, aFO.getFormatter().getClass()); assertEquals("x [Any]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new StringSuffixFormatter(" y")); assertEquals("Any", aFO.getValue()); assertEquals(StringSuffixFormatter.class, aFO.getFormatter().getClass()); assertEquals("Any y", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new StringSuffixFormatter(new BracketFormatter(), " y")); assertEquals("Any", aFO.getValue()); assertEquals(StringSuffixFormatter.class, aFO.getFormatter().getClass()); assertEquals("[Any] y", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new MinLengthAddLeadingFormatter(10, '@')); assertEquals("Any", aFO.getValue()); assertEquals(MinLengthAddLeadingFormatter.class, aFO.getFormatter().getClass()); assertEquals("@@@@@@@Any", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject( "Any", new MinLengthAddLeadingFormatter(new BracketFormatter(), 10, '@')); assertEquals("Any", aFO.getValue()); assertEquals(MinLengthAddLeadingFormatter.class, aFO.getFormatter().getClass()); assertEquals("@@@@@[Any]", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject("Any", new MinLengthAddTrailingFormatter(10, '@')); assertEquals("Any", aFO.getValue()); assertEquals(MinLengthAddTrailingFormatter.class, aFO.getFormatter().getClass()); assertEquals("Any@@@@@@@", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); aFO = new FormattedObject( "Any", new MinLengthAddTrailingFormatter(new BracketFormatter(), 10, '@')); assertEquals("Any", aFO.getValue()); assertEquals(MinLengthAddTrailingFormatter.class, aFO.getFormatter().getClass()); assertEquals("[Any]@@@@@", aFO.getAsString()); PhlocTestUtils.testToStringImplementation(aFO); }
@Test public void testImpl() { PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new FormattedObject("Any", new BracketFormatter()), new FormattedObject("Any", new BracketFormatter())); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new FormattedObject("Any", new BracketFormatter()), new FormattedObject("Any2", new BracketFormatter())); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new FormattedObject("Any", new BracketFormatter()), new FormattedObject("Any", new StringPrefixFormatter("oprefix"))); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new BracketFormatter(), new BracketFormatter()); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new MinLengthAddLeadingFormatter(10, ' '), new MinLengthAddLeadingFormatter(10, ' ')); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new MinLengthAddLeadingFormatter(10, ' '), new MinLengthAddLeadingFormatter(10, 'x')); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new MinLengthAddLeadingFormatter(10, ' '), new MinLengthAddLeadingFormatter(5, ' ')); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new MinLengthAddTrailingFormatter(10, ' '), new MinLengthAddTrailingFormatter(10, ' ')); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new MinLengthAddTrailingFormatter(10, ' '), new MinLengthAddTrailingFormatter(10, 'x')); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new MinLengthAddTrailingFormatter(10, ' '), new MinLengthAddTrailingFormatter(5, ' ')); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new StringPrefixAndSuffixFormatter("p", "s"), new StringPrefixAndSuffixFormatter("p", "s")); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new StringPrefixAndSuffixFormatter("p", "s"), new StringPrefixAndSuffixFormatter("p", "ss")); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new StringPrefixAndSuffixFormatter("p", "s"), new StringPrefixAndSuffixFormatter("pp", "s")); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new StringPrefixFormatter("p"), new StringPrefixFormatter("p")); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new StringPrefixFormatter("p"), new StringPrefixFormatter("pp")); PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new StringSuffixFormatter("s"), new StringSuffixFormatter("s")); PhlocTestUtils.testDefaultImplementationWithDifferentContentObject( new StringSuffixFormatter("s"), new StringSuffixFormatter("ss")); }
@Test public void testEqualsAndHashcode() { PhlocTestUtils.testDefaultImplementationWithEqualContentObject( new URLResourceProvider(), new URLResourceProvider()); }