Skip to content

Commit 11adc54

Browse files
committed
Merge pull request #114 from GoogleCloudPlatform/teststyle
Checkstyle fix for unittests samples.
2 parents 34c48c3 + 8620489 commit 11adc54

11 files changed

+84
-59
lines changed

unittests/src/test/java/com/google/appengine/samples/AuthenticationTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,20 +13,22 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START AuthenticationTest]
1920

21+
import static org.junit.Assert.assertTrue;
22+
2023
import com.google.appengine.api.users.UserService;
2124
import com.google.appengine.api.users.UserServiceFactory;
2225
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
2326
import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig;
27+
2428
import org.junit.After;
2529
import org.junit.Before;
2630
import org.junit.Test;
2731

28-
import static org.junit.Assert.assertTrue;
29-
3032
public class AuthenticationTest {
3133

3234
private final LocalServiceTestHelper helper =

unittests/src/test/java/com/google/appengine/samples/DeferredTaskTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,23 +13,25 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START DeferredTaskTest]
1920

21+
import static org.junit.Assert.assertTrue;
22+
2023
import com.google.appengine.api.taskqueue.DeferredTask;
2124
import com.google.appengine.api.taskqueue.QueueFactory;
2225
import com.google.appengine.api.taskqueue.TaskOptions;
2326
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
2427
import com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig;
28+
2529
import org.junit.After;
2630
import org.junit.Before;
2731
import org.junit.Test;
2832

2933
import java.util.concurrent.TimeUnit;
3034

31-
import static org.junit.Assert.assertTrue;
32-
3335
public class DeferredTaskTest {
3436

3537
// Unlike CountDownLatch, TaskCountDownlatch lets us reset.

unittests/src/test/java/com/google/appengine/samples/LocalCustomPolicyHighRepDatastoreTest.java

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,35 +13,41 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START LocalCustomPolicyHighRepDatastoreTest]
1920

20-
import com.google.appengine.api.datastore.*;
21+
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
22+
import static org.junit.Assert.assertEquals;
23+
24+
import com.google.appengine.api.datastore.DatastoreService;
25+
import com.google.appengine.api.datastore.DatastoreServiceFactory;
26+
import com.google.appengine.api.datastore.Entity;
27+
import com.google.appengine.api.datastore.Key;
28+
import com.google.appengine.api.datastore.Query;
2129
import com.google.appengine.api.datastore.dev.HighRepJobPolicy;
2230
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
2331
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
32+
2433
import org.junit.After;
2534
import org.junit.Before;
2635
import org.junit.Test;
2736

28-
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
29-
import static org.junit.Assert.assertEquals;
30-
3137
public class LocalCustomPolicyHighRepDatastoreTest {
3238
private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
3339
static int newJobCounter = 0;
3440
static int existingJobCounter = 0;
3541

3642
@Override
3743
public boolean shouldApplyNewJob(Key entityGroup) {
38-
// every other new job fails to apply
44+
// Every other new job fails to apply.
3945
return newJobCounter++ % 2 == 0;
4046
}
4147

4248
@Override
4349
public boolean shouldRollForwardExistingJob(Key entityGroup) {
44-
// every other existing job fails to apply
50+
// Every other existing job fails to apply.
4551
return existingJobCounter++ % 2 == 0;
4652
}
4753
}
@@ -65,10 +71,10 @@ public void testEventuallyConsistentGlobalQueryResult() {
6571
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
6672
ds.put(new Entity("yam")); // applies
6773
ds.put(new Entity("yam")); // does not apply
68-
// first global query only sees the first Entity
74+
// First global query only sees the first Entity.
6975
assertEquals(1, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
70-
// second global query sees both Entities because we "groom" (attempt to
71-
// apply unapplied jobs) after every query
76+
// Second global query sees both Entities because we "groom" (attempt to
77+
// apply unapplied jobs) after every query.
7278
assertEquals(2, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
7379
}
7480
}

unittests/src/test/java/com/google/appengine/samples/LocalDatastoreTest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,23 +13,25 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START LocalDatastoreTest]
1920

21+
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
22+
import static org.junit.Assert.assertEquals;
23+
2024
import com.google.appengine.api.datastore.DatastoreService;
2125
import com.google.appengine.api.datastore.DatastoreServiceFactory;
2226
import com.google.appengine.api.datastore.Entity;
2327
import com.google.appengine.api.datastore.Query;
2428
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
2529
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
30+
2631
import org.junit.After;
2732
import org.junit.Before;
2833
import org.junit.Test;
2934

30-
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
31-
import static org.junit.Assert.assertEquals;
32-
3335
public class LocalDatastoreTest {
3436

3537
private final LocalServiceTestHelper helper =
@@ -45,7 +47,7 @@ public void tearDown() {
4547
helper.tearDown();
4648
}
4749

48-
// run this test twice to prove we're not leaking any state across tests
50+
// Run this test twice to prove we're not leaking any state across tests.
4951
private void doTest() {
5052
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
5153
assertEquals(0, ds.prepare(new Query("yam")).countEntities(withLimit(10)));

unittests/src/test/java/com/google/appengine/samples/LocalHighRepDatastoreTest.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,19 +18,25 @@
1818

1919
// [START LocalHighRepDatastoreTest]
2020

21-
import com.google.appengine.api.datastore.*;
21+
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
22+
import static org.junit.Assert.assertEquals;
23+
24+
import com.google.appengine.api.datastore.DatastoreService;
25+
import com.google.appengine.api.datastore.DatastoreServiceFactory;
26+
import com.google.appengine.api.datastore.Entity;
27+
import com.google.appengine.api.datastore.Key;
28+
import com.google.appengine.api.datastore.KeyFactory;
29+
import com.google.appengine.api.datastore.Query;
2230
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
2331
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
32+
2433
import org.junit.After;
2534
import org.junit.Before;
2635
import org.junit.Test;
2736

28-
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
29-
import static org.junit.Assert.assertEquals;
30-
3137
public class LocalHighRepDatastoreTest {
3238

33-
// maximum eventual consistency
39+
// Maximum eventual consistency.
3440
private final LocalServiceTestHelper helper =
3541
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
3642
.setDefaultHighRepJobPolicyUnappliedJobPercentage(100));
@@ -51,9 +57,9 @@ public void testEventuallyConsistentGlobalQueryResult() {
5157
Key ancestor = KeyFactory.createKey("foo", 3);
5258
ds.put(new Entity("yam", ancestor));
5359
ds.put(new Entity("yam", ancestor));
54-
// global query doesn't see the data
60+
// Global query doesn't see the data.
5561
assertEquals(0, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
56-
// ancestor query does see the data
62+
// Ancestor query does see the data.
5763
assertEquals(2, ds.prepare(new Query("yam", ancestor)).countEntities(withLimit(10)));
5864
}
5965
}

unittests/src/test/java/com/google/appengine/samples/LocalMemcacheTest.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,23 +13,25 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertTrue;
1821

1922
// [START imports]
23+
2024
import com.google.appengine.api.memcache.MemcacheService;
2125
import com.google.appengine.api.memcache.MemcacheServiceFactory;
2226
import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig;
2327
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
28+
2429
// [END imports]
2530

2631
import org.junit.After;
2732
import org.junit.Before;
2833
import org.junit.Test;
2934

30-
import static org.junit.Assert.assertFalse;
31-
import static org.junit.Assert.assertTrue;
32-
3335
// [START NameAndHelper]
3436
public class LocalMemcacheTest {
3537

@@ -48,8 +50,7 @@ public void tearDown() {
4850
helper.tearDown();
4951
}
5052

51-
// run this test twice to prove we're not leaking any state across tests
52-
53+
// Run this test twice to prove we're not leaking any state across tests.
5354
// [START doTest]
5455
private void doTest() {
5556
MemcacheService ms = MemcacheServiceFactory.getMemcacheService();

unittests/src/test/java/com/google/appengine/samples/MyFirstTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,9 +18,9 @@
1818

1919
// [START MyFirstTest]
2020

21-
import org.junit.Test;
21+
import static org.junit.Assert.assertEquals;
2222

23-
import static org.junit.Assert.*;
23+
import org.junit.Test;
2424

2525
public class MyFirstTest {
2626
@Test

unittests/src/test/java/com/google/appengine/samples/OAuthTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,22 +13,24 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START OAuthTest]
1920

21+
import static org.junit.Assert.assertEquals;
22+
2023
import com.google.appengine.api.oauth.OAuthRequestException;
2124
import com.google.appengine.api.oauth.OAuthService;
2225
import com.google.appengine.api.oauth.OAuthServiceFactory;
2326
import com.google.appengine.api.users.User;
2427
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
2528
import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig;
29+
2630
import org.junit.After;
2731
import org.junit.Before;
2832
import org.junit.Test;
2933

30-
import static org.junit.Assert.assertEquals;
31-
3234
public class OAuthTest {
3335
private static final String OAUTH_CONSUMER_KEY = "notexample.com";
3436
private static final String OAUTH_EMAIL = "[email protected]";

unittests/src/test/java/com/google/appengine/samples/ShortTest.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2015 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,10 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.appengine.samples;
1718

1819
// [START ShortTest]
1920

21+
import static org.junit.Assert.assertEquals;
22+
2023
import com.google.appengine.api.capabilities.Capability;
2124
import com.google.appengine.api.capabilities.CapabilityStatus;
2225
import com.google.appengine.api.datastore.DatastoreService;
@@ -26,11 +29,10 @@
2629
import com.google.appengine.tools.development.testing.LocalCapabilitiesServiceTestConfig;
2730
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
2831
import com.google.apphosting.api.ApiProxy;
32+
2933
import org.junit.After;
3034
import org.junit.Test;
3135

32-
import static org.junit.Assert.assertEquals;
33-
3436
public class ShortTest {
3537
private LocalServiceTestHelper helper;
3638

@@ -39,12 +41,11 @@ public void tearDown() {
3941
helper.tearDown();
4042
}
4143

42-
4344
@Test(expected = ApiProxy.CapabilityDisabledException.class)
4445
public void testDisabledDatastore() {
4546
Capability testOne = new Capability("datastore_v3");
4647
CapabilityStatus testStatus = CapabilityStatus.DISABLED;
47-
//Initialize
48+
// Initialize the test configuration.
4849
LocalCapabilitiesServiceTestConfig config =
4950
new LocalCapabilitiesServiceTestConfig().setCapabilityStatus(testOne, testStatus);
5051
helper = new LocalServiceTestHelper(config);

0 commit comments

Comments
 (0)