mirror of
https://gitee.com/dcren/initializr.git
synced 2026-09-19 14:27:41 +08:00
Polish
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2018 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -718,7 +718,7 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
request.getBuildProperties().getMaven().put("ignore.property", () -> "yes");
|
request.getBuildProperties().getMaven().put("ignore.property", () -> "yes");
|
||||||
|
|
||||||
generateGradleBuild(request).contains("name = 'test'")
|
generateGradleBuild(request).contains("name = 'test'")
|
||||||
.hasBuildProperties("foo.version=1.2.3", "internalVersion=4.5.6")
|
.hasProperties("foo.version", "1.2.3", "internalVersion", "4.5.6")
|
||||||
.doesNotContain("ignore.property");
|
.doesNotContain("ignore.property");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-7
@@ -63,13 +63,20 @@ public class GradleBuildAssert {
|
|||||||
return contains("maven { url \"" + url + "\" }");
|
return contains("maven { url \"" + url + "\" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradleBuildAssert hasBuildProperties(String... pairs) {
|
/**
|
||||||
StringBuilder builder = new StringBuilder("ext {\n");
|
* Assert the build contains only the specified properties
|
||||||
for (String pair : pairs) {
|
* @param values the property value pairs
|
||||||
int index = pair.indexOf('=');
|
* @return this for method chaining.
|
||||||
String name = (index > 0) ? pair.substring(0, index) : pair;
|
*/
|
||||||
String value = (index > 0) ? pair.substring(index + 1) : "";
|
public GradleBuildAssert hasProperties(String... values) {
|
||||||
builder.append("\tset('" + name + "', '" + value + "')\n");
|
StringBuilder builder = new StringBuilder(String.format("ext {%n"));
|
||||||
|
if (values.length % 2 == 1) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Size must be even, it is a set of property=value pairs");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < values.length; i += 2) {
|
||||||
|
builder.append(
|
||||||
|
String.format("\tset('%s', '%s')%n", values[i], values[i + 1]));
|
||||||
}
|
}
|
||||||
builder.append("}");
|
builder.append("}");
|
||||||
return contains(builder.toString());
|
return contains(builder.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user