@@ -120,6 +120,18 @@ public void should_remove_header_when_empty() throws Throwable {
120
120
.test (getTestResource ("license/HasLicense.test" ), getTestResource ("license/MissingLicense.test" ));
121
121
}
122
122
123
+ private String licenceWithAddress () {
124
+ return "Copyright © $YEAR FooBar Inc. All Rights Reserved.\n " +
125
+ " *\n " +
126
+ " * Use of this software is covered by inscrutable legal protection and\n " +
127
+ " * complex automation. Violaters of undisclosed terms must expect\n " +
128
+ " * unforeseen consequences.\n " +
129
+ " *\n " +
130
+ " * FooBar, Inc.\n " +
131
+ " * 9 Food Truck\n " +
132
+ " * Perry Derry, TX 55656 USA" ;
133
+ }
134
+
123
135
private String header (String contents ) throws IOException {
124
136
return "/*\n " +
125
137
" * " + contents + "\n " +
@@ -212,4 +224,20 @@ public void should_apply_license_containing_YEAR_token_in_range() throws Throwab
212
224
FormatterStep step = LicenseHeaderStep .headerDelimiter (header (HEADER_WITH_RANGE_TO_$YEAR ), package_ ).withYearMode (YearMode .UPDATE_TO_TODAY ).build ();
213
225
StepHarness .forStep (step ).test (hasHeaderWithRangeAndWithYearTo ("2015" ), hasHeaderWithRangeAndWithYearTo (currentYear ()));
214
226
}
227
+
228
+ @ Test
229
+ public void should_update_year_for_license_with_address () throws Throwable {
230
+ FormatterStep step = LicenseHeaderStep .headerDelimiter (header (licenceWithAddress ()), package_ ).withYearMode (YearMode .UPDATE_TO_TODAY ).build ();
231
+ StepHarness .forStep (step ).test (
232
+ hasHeader (licenceWithAddress ().replace ("$YEAR" , "2015" )),
233
+ hasHeader (licenceWithAddress ().replace ("$YEAR" , "2015-2021" )));
234
+ }
235
+
236
+ @ Test
237
+ public void should_preserve_year_for_license_with_address () throws Throwable {
238
+ FormatterStep step = LicenseHeaderStep .headerDelimiter (header (licenceWithAddress ()), package_ ).withYearMode (YearMode .PRESERVE ).build ();
239
+ StepHarness .forStep (step ).test (
240
+ hasHeader (licenceWithAddress ().replace ("$YEAR" , "2015" ).replace ("FooBar Inc. All" , "FooBar Inc. All" )),
241
+ hasHeader (licenceWithAddress ().replace ("$YEAR" , "2015" )));
242
+ }
215
243
}
0 commit comments