Move SerializedClassSubject to a more common location
Previously, SerializedClassSubject was only used for CacheSerializer tests. With the addition of ProtoConverters, we need exactly the same test helpers again. To reduce code duplication and avoid strange dependencies, move the Truth subject to a more common package. Change-Id: Iafdc5fc5efcb1a7ee4a9335eeac3b5fdd5f443c0
This commit is contained in:
13
java/com/google/gerrit/proto/testing/BUILD
Normal file
13
java/com/google/gerrit/proto/testing/BUILD
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package(default_testonly = 1)
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = "testing",
|
||||||
|
srcs = glob(["*.java"]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [
|
||||||
|
"//java/com/google/gerrit/server/cache/serialize",
|
||||||
|
"//lib:guava",
|
||||||
|
"//lib/commons:lang3",
|
||||||
|
"//lib/truth",
|
||||||
|
],
|
||||||
|
)
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.gerrit.server.cache.testing;
|
package com.google.gerrit.proto.testing;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
import static com.google.common.truth.Truth.assertAbout;
|
import static com.google.common.truth.Truth.assertAbout;
|
||||||
@@ -30,13 +30,14 @@ import java.util.Map;
|
|||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subject about classes that are serialized into persistent caches.
|
* Subject about classes that are serialized into persistent caches or indices.
|
||||||
*
|
*
|
||||||
* <p>Hand-written {@link com.google.gerrit.server.cache.serialize.CacheSerializer CacheSerializer}
|
* <p>Hand-written {@link com.google.gerrit.server.cache.serialize.CacheSerializer CacheSerializer}
|
||||||
* implementations depend on the exact representation of the data stored in a class, so it is
|
* and {@link com.google.gerrit.reviewdb.converter.ProtoConverter ProtoConverter} implementations
|
||||||
* important to verify any assumptions about the structure of the serialized classes. This class
|
* depend on the exact representation of the data stored in a class, so it is important to verify
|
||||||
* contains assertions about serialized classes, and should be used for every class that has a
|
* any assumptions about the structure of the serialized classes. This class contains assertions
|
||||||
* custom serializer implementation.
|
* about serialized classes, and should be used for every class that has a custom serializer
|
||||||
|
* implementation.
|
||||||
*
|
*
|
||||||
* <p>Changing fields of a serialized class (or abstract methods, in the case of {@code @AutoValue}
|
* <p>Changing fields of a serialized class (or abstract methods, in the case of {@code @AutoValue}
|
||||||
* classes) will likely require changes to the serializer implementation, and may require bumping
|
* classes) will likely require changes to the serializer implementation, and may require bumping
|
||||||
@@ -5,10 +5,6 @@ java_library(
|
|||||||
srcs = glob(["*.java"]),
|
srcs = glob(["*.java"]),
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//java/com/google/gerrit/server/cache/serialize",
|
|
||||||
"//lib:guava",
|
|
||||||
"//lib:protobuf",
|
"//lib:protobuf",
|
||||||
"//lib/commons:lang3",
|
|
||||||
"//lib/truth",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ package com.google.gerrit.reviewdb.converter;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.protobuf.Parser;
|
import com.google.protobuf.Parser;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -58,10 +59,7 @@ public class AccountIdProtoConverterTest {
|
|||||||
assertThat(parsedProto).isEqualTo(proto);
|
assertThat(parsedProto).isEqualTo(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldsExistAsExpected() {
|
public void fieldsExistAsExpected() {
|
||||||
assertThatSerializedClass(Account.Id.class).hasFields(ImmutableMap.of("id", int.class));
|
assertThatSerializedClass(Account.Id.class).hasFields(ImmutableMap.of("id", int.class));
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ junit_tests(
|
|||||||
exclude = COMPATIBLITY_TEST_SRCS,
|
exclude = COMPATIBLITY_TEST_SRCS,
|
||||||
),
|
),
|
||||||
deps = [
|
deps = [
|
||||||
|
"//java/com/google/gerrit/proto/testing",
|
||||||
"//java/com/google/gerrit/reviewdb:server",
|
"//java/com/google/gerrit/reviewdb:server",
|
||||||
"//java/com/google/gerrit/server/cache/testing",
|
|
||||||
"//lib:guava",
|
"//lib:guava",
|
||||||
"//lib:protobuf",
|
"//lib:protobuf",
|
||||||
"//lib/truth",
|
"//lib/truth",
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ package com.google.gerrit.reviewdb.converter;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.protobuf.Parser;
|
import com.google.protobuf.Parser;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -58,10 +59,7 @@ public class ChangeIdProtoConverterTest {
|
|||||||
assertThat(parsedProto).isEqualTo(proto);
|
assertThat(parsedProto).isEqualTo(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldsExistAsExpected() {
|
public void fieldsExistAsExpected() {
|
||||||
assertThatSerializedClass(Change.Id.class).hasFields(ImmutableMap.of("id", int.class));
|
assertThatSerializedClass(Change.Id.class).hasFields(ImmutableMap.of("id", int.class));
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ package com.google.gerrit.reviewdb.converter;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.protobuf.Parser;
|
import com.google.protobuf.Parser;
|
||||||
@@ -69,10 +70,7 @@ public class PatchSetIdProtoConverterTest {
|
|||||||
assertThat(parsedProto).isEqualTo(proto);
|
assertThat(parsedProto).isEqualTo(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldsExistAsExpected() {
|
public void fieldsExistAsExpected() {
|
||||||
assertThatSerializedClass(PatchSet.Id.class)
|
assertThatSerializedClass(PatchSet.Id.class)
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
package com.google.gerrit.reviewdb.converter;
|
package com.google.gerrit.reviewdb.converter;
|
||||||
|
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.truth.Truth;
|
import com.google.common.truth.Truth;
|
||||||
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -118,10 +119,7 @@ public class PatchSetProtoConverterTest {
|
|||||||
assertThat(parsedProto).isEqualTo(proto);
|
assertThat(parsedProto).isEqualTo(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldsExistAsExpected() {
|
public void fieldsExistAsExpected() {
|
||||||
assertThatSerializedClass(PatchSet.class)
|
assertThatSerializedClass(PatchSet.class)
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ package com.google.gerrit.reviewdb.converter;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
import com.google.gerrit.proto.reviewdb.Reviewdb;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
import com.google.gerrit.reviewdb.client.RevId;
|
||||||
import com.google.protobuf.Parser;
|
import com.google.protobuf.Parser;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -57,10 +58,7 @@ public class RevIdProtoConverterTest {
|
|||||||
assertThat(parsedProto).isEqualTo(proto);
|
assertThat(parsedProto).isEqualTo(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void fieldsExistAsExpected() {
|
public void fieldsExistAsExpected() {
|
||||||
assertThatSerializedClass(RevId.class).hasFields(ImmutableMap.of("id", String.class));
|
assertThatSerializedClass(RevId.class).hasFields(ImmutableMap.of("id", String.class));
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ junit_tests(
|
|||||||
"//java/com/google/gerrit/mail",
|
"//java/com/google/gerrit/mail",
|
||||||
"//java/com/google/gerrit/metrics",
|
"//java/com/google/gerrit/metrics",
|
||||||
"//java/com/google/gerrit/proto",
|
"//java/com/google/gerrit/proto",
|
||||||
|
"//java/com/google/gerrit/proto/testing",
|
||||||
"//java/com/google/gerrit/reviewdb:server",
|
"//java/com/google/gerrit/reviewdb:server",
|
||||||
"//java/com/google/gerrit/server",
|
"//java/com/google/gerrit/server",
|
||||||
"//java/com/google/gerrit/server/cache/serialize",
|
"//java/com/google/gerrit/server/cache/serialize",
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ package com.google.gerrit.server.account.externalids;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package com.google.gerrit.server.auth.oauth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.server.cache.proto.Cache.OAuthTokenProto;
|
import com.google.gerrit.server.cache.proto.Cache.OAuthTokenProto;
|
||||||
import com.google.gerrit.server.cache.serialize.CacheSerializer;
|
import com.google.gerrit.server.cache.serialize.CacheSerializer;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@@ -56,10 +57,7 @@ public final class OAuthTokenCacheTest {
|
|||||||
assertThat(s.deserialize(serializedWithEmptyString)).isEqualTo(tokenWithNull);
|
assertThat(s.deserialize(serializedWithEmptyString)).isEqualTo(tokenWithNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void oAuthTokenFields() throws Exception {
|
public void oAuthTokenFields() throws Exception {
|
||||||
assertThatSerializedClass(OAuthToken.class)
|
assertThatSerializedClass(OAuthToken.class)
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.server.cache.proto.Cache.ChangeKindKeyProto;
|
import com.google.gerrit.server.cache.proto.Cache.ChangeKindKeyProto;
|
||||||
import com.google.gerrit.server.cache.serialize.CacheSerializer;
|
import com.google.gerrit.server.cache.serialize.CacheSerializer;
|
||||||
import com.google.gerrit.server.change.ChangeKindCacheImpl.Key;
|
import com.google.gerrit.server.change.ChangeKindCacheImpl.Key;
|
||||||
@@ -50,10 +51,7 @@ public class ChangeKindCacheImplTest extends GerritBaseTests {
|
|||||||
assertThat(s.deserialize(serialized)).isEqualTo(key);
|
assertThat(s.deserialize(serialized)).isEqualTo(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void keyFields() throws Exception {
|
public void keyFields() throws Exception {
|
||||||
assertThatSerializedClass(ChangeKindCacheImpl.Key.class)
|
assertThatSerializedClass(ChangeKindCacheImpl.Key.class)
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.server.cache.proto.Cache.MergeabilityKeyProto;
|
import com.google.gerrit.server.cache.proto.Cache.MergeabilityKeyProto;
|
||||||
import com.google.gerrit.testing.GerritBaseTests;
|
import com.google.gerrit.testing.GerritBaseTests;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
@@ -54,10 +55,7 @@ public class MergeabilityCacheImplTest extends GerritBaseTests {
|
|||||||
.isEqualTo(key);
|
.isEqualTo(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void keyFields() throws Exception {
|
public void keyFields() throws Exception {
|
||||||
assertThatSerializedClass(MergeabilityCacheImpl.EntryKey.class)
|
assertThatSerializedClass(MergeabilityCacheImpl.EntryKey.class)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ package com.google.gerrit.server.git;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ package com.google.gerrit.server.git;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ package com.google.gerrit.server.notedb;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.proto.Protos.toByteString;
|
import static com.google.gerrit.proto.Protos.toByteString;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.MESSAGE_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.MESSAGE_CODEC;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
import static com.google.gerrit.server.notedb.ChangeNotesState.Serializer.toByteString;
|
import static com.google.gerrit.server.notedb.ChangeNotesState.Serializer.toByteString;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ junit_tests(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//java/com/google/gerrit/extensions:api",
|
"//java/com/google/gerrit/extensions:api",
|
||||||
|
"//java/com/google/gerrit/proto/testing",
|
||||||
"//java/com/google/gerrit/reviewdb:server",
|
"//java/com/google/gerrit/reviewdb:server",
|
||||||
"//java/com/google/gerrit/server",
|
"//java/com/google/gerrit/server",
|
||||||
"//java/com/google/gerrit/server/cache/testing",
|
"//java/com/google/gerrit/server/cache/testing",
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||||
import static com.google.gerrit.extensions.client.SubmitType.FAST_FORWARD_ONLY;
|
import static com.google.gerrit.extensions.client.SubmitType.FAST_FORWARD_ONLY;
|
||||||
import static com.google.gerrit.extensions.client.SubmitType.MERGE_IF_NECESSARY;
|
import static com.google.gerrit.extensions.client.SubmitType.MERGE_IF_NECESSARY;
|
||||||
|
import static com.google.gerrit.proto.testing.SerializedClassSubject.assertThatSerializedClass;
|
||||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteString;
|
||||||
import static com.google.gerrit.server.cache.testing.SerializedClassSubject.assertThatSerializedClass;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
|
import com.google.gerrit.proto.testing.SerializedClassSubject;
|
||||||
import com.google.gerrit.server.cache.proto.Cache.ConflictKeyProto;
|
import com.google.gerrit.server.cache.proto.Cache.ConflictKeyProto;
|
||||||
import com.google.gerrit.testing.GerritBaseTests;
|
import com.google.gerrit.testing.GerritBaseTests;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
@@ -82,10 +83,7 @@ public class ConflictKeyTest extends GerritBaseTests {
|
|||||||
assertThat(ConflictKey.Serializer.INSTANCE.deserialize(serialized)).isEqualTo(key);
|
assertThat(ConflictKey.Serializer.INSTANCE.deserialize(serialized)).isEqualTo(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
|
||||||
* See {@link com.google.gerrit.server.cache.testing.SerializedClassSubject} for background and
|
|
||||||
* what to do if this test fails.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void methods() throws Exception {
|
public void methods() throws Exception {
|
||||||
assertThatSerializedClass(ConflictKey.class)
|
assertThatSerializedClass(ConflictKey.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user