Move ByteString bytes(int... ints) to test util
Change-Id: If55dac7c1a2df87c412bf0e13afb7a9b57fbfa95
This commit is contained in:
parent
095394c069
commit
cc7b9a82e3
java/com/google/gerrit/server/cache/testing
javatests/com/google/gerrit/server/change
@ -6,6 +6,7 @@ java_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//lib:guava",
|
||||
"//lib:protobuf",
|
||||
"//lib:truth",
|
||||
"//lib/commons:lang3",
|
||||
],
|
||||
|
30
java/com/google/gerrit/server/cache/testing/CacheSerializerTestUtil.java
vendored
Normal file
30
java/com/google/gerrit/server/cache/testing/CacheSerializerTestUtil.java
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.cache.testing;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
/** Static utilities for testing cache serializers. */
|
||||
public class CacheSerializerTestUtil {
|
||||
public static ByteString bytes(int... ints) {
|
||||
byte[] bytes = new byte[ints.length];
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
bytes[i] = (byte) ints[i];
|
||||
}
|
||||
return ByteString.copyFrom(bytes);
|
||||
}
|
||||
|
||||
private CacheSerializerTestUtil() {}
|
||||
}
|
@ -15,12 +15,12 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.bytes;
|
||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.server.cache.CacheSerializer;
|
||||
import com.google.gerrit.server.cache.proto.Cache.ChangeKindKeyProto;
|
||||
import com.google.protobuf.ByteString;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -58,12 +58,4 @@ public class ChangeKindCacheImplTest {
|
||||
ImmutableMap.of(
|
||||
"prior", ObjectId.class, "next", ObjectId.class, "strategyName", String.class));
|
||||
}
|
||||
|
||||
private static ByteString bytes(int... ints) {
|
||||
byte[] bytes = new byte[ints.length];
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
bytes[i] = (byte) ints[i];
|
||||
}
|
||||
return ByteString.copyFrom(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,12 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.bytes;
|
||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.server.cache.proto.Cache.MergeabilityKeyProto;
|
||||
import com.google.protobuf.ByteString;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -66,12 +66,4 @@ public class MergeabilityCacheImplTest {
|
||||
"submitType", SubmitType.class,
|
||||
"mergeStrategy", String.class));
|
||||
}
|
||||
|
||||
private static ByteString bytes(int... ints) {
|
||||
byte[] bytes = new byte[ints.length];
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
bytes[i] = (byte) ints[i];
|
||||
}
|
||||
return ByteString.copyFrom(bytes);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user