public Optional<ClassName> findTestee(final String className) { final TestToClassMapper mapper = new TestToClassMapper(this.classRepository); return mapper.findTestee(className); }
public Optional<ClassName> findTestee(final String className) { final ClassName name = ClassName.fromString(className); if (name.asJavaName().endsWith("Test") && tryName(name.withoutSuffixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutSuffixChars(TEST_LENGTH)); } if (name.getNameWithoutPackage().asJavaName().startsWith("Test") && tryName(name.withoutPrefixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutPrefixChars(TEST_LENGTH)); } return Optional.empty(); }
@Test public void shouldReturnNoneWhenNoTesteeExistsMatchingNamingConvention() { final byte[] bytes = null; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(Optional.empty(), this.testee.findTestee("com.example.TestFoo")); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.repository = new Repository(this.source); this.testee = new TestToClassMapper(this.repository); }
@Test public void shouldReturnNoneWhenNoTesteeExistsMatchingNamingConvention() { final byte[] bytes = null; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(Optional.empty(), this.testee.findTestee("com.example.TestFoo")); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.repository = new Repository(this.source); this.testee = new TestToClassMapper(this.repository); }
public Optional<ClassName> findTestee(final String className) { final TestToClassMapper mapper = new TestToClassMapper(this.classRepository); return mapper.findTestee(className); }
@Test public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(ClassName.fromString("com.example.Foo"), this.testee.findTestee("com.example.FooTest").get()); }
public Optional<ClassName> findTestee(final String className) { final ClassName name = ClassName.fromString(className); if (name.asJavaName().endsWith("Test") && tryName(name.withoutSuffixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutSuffixChars(TEST_LENGTH)); } if (name.getNameWithoutPackage().asJavaName().startsWith("Test") && tryName(name.withoutPrefixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutPrefixChars(TEST_LENGTH)); } return Optional.empty(); }
@Test public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(ClassName.fromString("com.example.Foo"), this.testee.findTestee("com.example.TestFoo").get()); }
public Optional<ClassName> findTestee(final String className) { final ClassName name = ClassName.fromString(className); if (name.asJavaName().endsWith("Test") && tryName(name.withoutSuffixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutSuffixChars(TEST_LENGTH)); } if (name.getNameWithoutPackage().asJavaName().startsWith("Test") && tryName(name.withoutPrefixChars(TEST_LENGTH))) { return Optional.ofNullable(name.withoutPrefixChars(TEST_LENGTH)); } return Optional.empty(); }
@Test public void shouldMapTestsPrefixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(ClassName.fromString("com.example.Foo"), this.testee.findTestee("com.example.TestFoo").get()); }
@Test public void shouldMapTestsPostfixedWithTestToTesteeWhenTesteeExists() { final byte[] bytes = { 0 }; when(this.source.getBytes("com.example.Foo")) .thenReturn(Optional.ofNullable(bytes)); assertEquals(ClassName.fromString("com.example.Foo"), this.testee.findTestee("com.example.FooTest").get()); }