Skip to content

Commit

Permalink
Test GradleSourceUtil.insert/removeDirectDependency
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-wyluda committed Aug 6, 2013
1 parent 9f132ba commit df87146
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public static String removeDependency(String source, String group, String name,

throw new UnremovableElementException();
}

public static String insertDirectDependency(String source, String group, String name)
{
// TODO
return source;
}

public static String removeDirectDependency(String source, String group, String name)
{
// TODO
return source;
}

public static String insertManagedDependency(String source, String group, String name, String version,
String configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,48 @@ public void testRemoveDependencyForException() throws UnremovableElementExceptio
"}";
GradleSourceUtil.removeDependency(source, "a", "b", "1.0", "compile");
}

@Test
public void testInsertDirectDependency()
{
String source = "" +
"dependencies {\n" +
" compile 'a:b:1.0'\n" +
"}";
String expected = "" +
"dependencies {\n" +
" compile 'a:b:1.0'\n" +
" direct handler: it, group: 'x', name: 'y'\n" +
"}";
String result = GradleSourceUtil.insertDirectDependency(source, "x", "y");
assertEquals(expected, result);
}

@Test
public void testRemoveDirectDependency()
{
String source = "" +
"dependencies {\n" +
" compile 'a:b:1.0'\n" +
" direct handler: it, group: 'x', name: 'y'\n" +
"}";
String expected = "" +
"dependencies {\n" +
" compile 'a:b:1.0'\n" +
"}";
String result = GradleSourceUtil.removeDirectDependency(source, "x", "y");
assertEquals(expected, result);
}

@Test(expected = UnremovableElementException.class)
public void testRemoveDirectDependencyForException()
{
String source = "" +
"dependencies {\n" +
" compile 'a:b:1.0'\n" +
"}";
GradleSourceUtil.removeDirectDependency(source, "x", "y");
}

@Test
public void testInsertManagedDependency()
Expand Down

0 comments on commit df87146

Please sign in to comment.