repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/offsettime/OffsetTimeAsStringCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.OffsetTime; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.offsettime; /** * <p> * Encodes and decodes {@code OffsetTime} values to and from * {@code BSON String}, such as {@code 10:15:30+01:00}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link OffsetTime#toString()}). * <p> * This type is <b>immutable</b>. */ public final class OffsetTimeAsStringCodec implements Codec<OffsetTime> { @Override public void encode( BsonWriter writer, OffsetTime value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public OffsetTime decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/offsettime/OffsetTimeAsStringCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.OffsetTime; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.offsettime; /** * <p> * Encodes and decodes {@code OffsetTime} values to and from * {@code BSON String}, such as {@code 10:15:30+01:00}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link OffsetTime#toString()}). * <p> * This type is <b>immutable</b>. */ public final class OffsetTimeAsStringCodec implements Codec<OffsetTime> { @Override public void encode( BsonWriter writer, OffsetTime value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public OffsetTime decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.period; /** * <p> * Encodes and decodes {@code Period} values to and from * {@code BSON Document}, such as {@code { years: 18, months: 1, days: 2 }}. * <p> * The values are stored using the following structure: * <ul> * <li>{@code years} (a non-null {@code Int32}); * <li>{@code months} (a non-null {@code Int32}); * <li>{@code days} (a non-null {@code Int32}). * </ul> * <p> * This type is <b>immutable</b>. */ public final class PeriodAsDocumentCodec implements Codec<Period> { private static final Map<String, Decoder<?>> FIELD_DECODERS; static { Map<String, Decoder<?>> fd = new HashMap<>(); fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.period; /** * <p> * Encodes and decodes {@code Period} values to and from * {@code BSON Document}, such as {@code { years: 18, months: 1, days: 2 }}. * <p> * The values are stored using the following structure: * <ul> * <li>{@code years} (a non-null {@code Int32}); * <li>{@code months} (a non-null {@code Int32}); * <li>{@code days} (a non-null {@code Int32}). * </ul> * <p> * This type is <b>immutable</b>. */ public final class PeriodAsDocumentCodec implements Codec<Period> { private static final Map<String, Decoder<?>> FIELD_DECODERS; static { Map<String, Decoder<?>> fd = new HashMap<>(); fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.period; /** * <p> * Encodes and decodes {@code Period} values to and from * {@code BSON Document}, such as {@code { years: 18, months: 1, days: 2 }}. * <p> * The values are stored using the following structure: * <ul> * <li>{@code years} (a non-null {@code Int32}); * <li>{@code months} (a non-null {@code Int32}); * <li>{@code days} (a non-null {@code Int32}). * </ul> * <p> * This type is <b>immutable</b>. */ public final class PeriodAsDocumentCodec implements Codec<Period> { private static final Map<String, Decoder<?>> FIELD_DECODERS; static { Map<String, Decoder<?>> fd = new HashMap<>(); fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null"); return translateDecodeExceptions(
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.period; /** * <p> * Encodes and decodes {@code Period} values to and from * {@code BSON Document}, such as {@code { years: 18, months: 1, days: 2 }}. * <p> * The values are stored using the following structure: * <ul> * <li>{@code years} (a non-null {@code Int32}); * <li>{@code months} (a non-null {@code Int32}); * <li>{@code days} (a non-null {@code Int32}). * </ul> * <p> * This type is <b>immutable</b>. */ public final class PeriodAsDocumentCodec implements Codec<Period> { private static final Map<String, Decoder<?>> FIELD_DECODERS; static { Map<String, Decoder<?>> fd = new HashMap<>(); fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null"); return translateDecodeExceptions(
() -> readDocument(reader, decoderContext, FIELD_DECODERS),
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec;
fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null"); return translateDecodeExceptions( () -> readDocument(reader, decoderContext, FIELD_DECODERS), val -> of(
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> Value getFieldValue( // Document document, // Object key, // Class<Value> clazz) { // // try { // Value value = document.get(key, clazz); // if (value == null) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is null", key // )); // } // return value; // } // catch (ClassCastException ex) { // throw new BsonInvalidOperationException(format( // "The value of the field %s is not of the type %s", // key, clazz.getName() // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static Document readDocument( // BsonReader reader, // DecoderContext decoderContext, // Map<String, Decoder<?>> fieldDecoders) { // // Document document = new Document(); // reader.readStartDocument(); // while (reader.readBsonType() != END_OF_DOCUMENT) { // String fieldName = reader.readName(); // if (fieldDecoders.containsKey(fieldName)) { // document.put( // fieldName, // fieldDecoders // .get(fieldName) // .decode(reader, decoderContext) // ); // } // else { // throw new BsonInvalidOperationException(format( // "The field %s is not expected here", fieldName // )); // } // } // reader.readEndDocument(); // return document; // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/period/PeriodAsDocumentCodec.java import org.bson.codecs.Decoder; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.getFieldValue; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.readDocument; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.time.Period.of; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import java.time.Period; import java.util.HashMap; import java.util.Map; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; fd.put("years", (r, dc) -> r.readInt32()); fd.put("months", (r, dc) -> r.readInt32()); fd.put("days", (r, dc) -> r.readInt32()); FIELD_DECODERS = unmodifiableMap(fd); } @Override public void encode( BsonWriter writer, Period value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeStartDocument(); writer.writeInt32("years", value.getYears()); writer.writeInt32("months", value.getMonths()); writer.writeInt32("days", value.getDays()); writer.writeEndDocument(); } @Override public Period decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null"); return translateDecodeExceptions( () -> readDocument(reader, decoderContext, FIELD_DECODERS), val -> of(
getFieldValue(val, "years", Integer.class),
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/duration/DurationAsStringCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Duration; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.duration; /** * <p> * Encodes and decodes {@code Duration} values to and from * {@code BSON String}, such as {@code PT10.100S}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link Duration#toString()}). * <p> * This type is <b>immutable</b>. */ public final class DurationAsStringCodec implements Codec<Duration> { @Override public void encode( BsonWriter writer, Duration value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public Duration decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/duration/DurationAsStringCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Duration; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.duration; /** * <p> * Encodes and decodes {@code Duration} values to and from * {@code BSON String}, such as {@code PT10.100S}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link Duration#toString()}). * <p> * This type is <b>immutable</b>. */ public final class DurationAsStringCodec implements Codec<Duration> { @Override public void encode( BsonWriter writer, Duration value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public Duration decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsStringCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON String}, such as {@code 2018-01-02T10:15:30Z}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link Instant#toString()}). * <p> * This type is <b>immutable</b>. */ public final class InstantAsStringCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public Instant decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsStringCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON String}, such as {@code 2018-01-02T10:15:30Z}. * <p> * The values are stored as {@code ISO-8601} formatted strings * (see {@link Instant#toString()}). * <p> * This type is <b>immutable</b>. */ public final class InstantAsStringCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.toString()); } @Override public Instant decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsDateTimeCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> void translateEncodeExceptions( // Supplier<Value> valueSupplier, // Consumer<Value> valueConsumer) { // // Value value = valueSupplier.get(); // try { // valueConsumer.accept(value); // } // catch (ArithmeticException | // DateTimeException | // NumberFormatException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateEncodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON DateTime}. * <p> * Note that the nanoseconds precision is lost. * <p> * This type is <b>immutable</b>. */ public final class InstantAsDateTimeCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> void translateEncodeExceptions( // Supplier<Value> valueSupplier, // Consumer<Value> valueConsumer) { // // Value value = valueSupplier.get(); // try { // valueConsumer.accept(value); // } // catch (ArithmeticException | // DateTimeException | // NumberFormatException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsDateTimeCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateEncodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON DateTime}. * <p> * Note that the nanoseconds precision is lost. * <p> * This type is <b>immutable</b>. */ public final class InstantAsDateTimeCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null");
translateEncodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsDateTimeCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> void translateEncodeExceptions( // Supplier<Value> valueSupplier, // Consumer<Value> valueConsumer) { // // Value value = valueSupplier.get(); // try { // valueConsumer.accept(value); // } // catch (ArithmeticException | // DateTimeException | // NumberFormatException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateEncodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON DateTime}. * <p> * Note that the nanoseconds precision is lost. * <p> * This type is <b>immutable</b>. */ public final class InstantAsDateTimeCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); translateEncodeExceptions( () -> value, val -> writer.writeDateTime(val.toEpochMilli()) ); } @Override public Instant decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value> void translateEncodeExceptions( // Supplier<Value> valueSupplier, // Consumer<Value> valueConsumer) { // // Value value = valueSupplier.get(); // try { // valueConsumer.accept(value); // } // catch (ArithmeticException | // DateTimeException | // NumberFormatException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/instant/InstantAsDateTimeCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateEncodeExceptions; import static java.util.Objects.requireNonNull; import java.time.Instant; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.instant; /** * <p> * Encodes and decodes {@code Instant} values to and from * {@code BSON DateTime}. * <p> * Note that the nanoseconds precision is lost. * <p> * This type is <b>immutable</b>. */ public final class InstantAsDateTimeCodec implements Codec<Instant> { @Override public void encode( BsonWriter writer, Instant value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); translateEncodeExceptions( () -> value, val -> writer.writeDateTime(val.toEpochMilli()) ); } @Override public Instant decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
cbartosiak/bson-codecs-jsr310
src/main/java/io/github/cbartosiak/bson/codecs/jsr310/zoneoffset/ZoneOffsetAsStringCodec.java
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // }
import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.ZoneOffset; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext;
/* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.zoneoffset; /** * <p> * Encodes and decodes {@code ZoneOffset} values to and from * {@code BSON String}, such as {@code +01:00}. * <p> * The values are stored as normalized IDs * (see {@link ZoneOffset#getId()}). * <p> * This type is <b>immutable</b>. */ public final class ZoneOffsetAsStringCodec implements Codec<ZoneOffset> { @Override public void encode( BsonWriter writer, ZoneOffset value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.getId()); } @Override public ZoneOffset decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
// Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/internal/CodecsUtil.java // public static <Value, Result> Result translateDecodeExceptions( // Supplier<Value> valueSupplier, // Function<Value, Result> valueConverter) { // // Value value = valueSupplier.get(); // try { // return valueConverter.apply(value); // } // catch (ArithmeticException | // DateTimeException | // IllegalArgumentException ex) { // // throw new BsonInvalidOperationException(format( // "The value %s is not supported", value // ), ex); // } // } // Path: src/main/java/io/github/cbartosiak/bson/codecs/jsr310/zoneoffset/ZoneOffsetAsStringCodec.java import static io.github.cbartosiak.bson.codecs.jsr310.internal.CodecsUtil.translateDecodeExceptions; import static java.util.Objects.requireNonNull; import java.time.ZoneOffset; import org.bson.BsonReader; import org.bson.BsonWriter; import org.bson.codecs.Codec; import org.bson.codecs.DecoderContext; import org.bson.codecs.EncoderContext; /* * Copyright 2018 Cezary Bartosiak * * 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 io.github.cbartosiak.bson.codecs.jsr310.zoneoffset; /** * <p> * Encodes and decodes {@code ZoneOffset} values to and from * {@code BSON String}, such as {@code +01:00}. * <p> * The values are stored as normalized IDs * (see {@link ZoneOffset#getId()}). * <p> * This type is <b>immutable</b>. */ public final class ZoneOffsetAsStringCodec implements Codec<ZoneOffset> { @Override public void encode( BsonWriter writer, ZoneOffset value, EncoderContext encoderContext) { requireNonNull(writer, "writer is null"); requireNonNull(value, "value is null"); writer.writeString(value.getId()); } @Override public ZoneOffset decode( BsonReader reader, DecoderContext decoderContext) { requireNonNull(reader, "reader is null");
return translateDecodeExceptions(
BraisGabin/couchbase-lite-orm
compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/ProcessorTest.java
// Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/TestProcessors.java // static Iterable<? extends javax.annotation.processing.Processor> processors() { // return Collections.singletonList( // new Processor() // ); // }
import com.google.testing.compile.JavaFileObjects; import org.junit.Before; import org.junit.Test; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import javax.tools.JavaFileObject; import static com.braisgabin.couchbaseliteorm.compiler.TestProcessors.processors; import static com.google.common.truth.Truth.ASSERT; import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource; import static com.google.testing.compile.JavaSourcesSubjectFactory.javaSources;
); } private static Path qualifiedNameToPath(String compilerPath, String sampleName, String fullyQualifiedName) { return Paths.get(compilerPath + "/../source-samples/" + sampleName + "/src/main/java/" + fullyQualifiedName.replaceAll("\\.", "/") + ".java"); } @Before public void init() { // FIXME this is a workaround. this.compilerPath = System.getProperty("compilerProjectPath"); if (this.compilerPath == null) { this.compilerPath = "./compiler"; } } @Test public void simpleCompile() throws IOException { final String sampleName = "simple"; final JavaFileObject inputFile = getJavaFileObject(compilerPath, sampleName, "com.samples.Person"); final JavaFileObject expectedFile1 = getJavaFileObject(compilerPath, sampleName, "com.samples.Person$$Mapper"); final JavaFileObject expectedFile2 = getJavaFileObject(compilerPath, sampleName, "com.braisgabin.couchbaseliteorm.CouchbaseLiteOrmInternal"); ASSERT.about(javaSource()) .that(inputFile)
// Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/TestProcessors.java // static Iterable<? extends javax.annotation.processing.Processor> processors() { // return Collections.singletonList( // new Processor() // ); // } // Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/ProcessorTest.java import com.google.testing.compile.JavaFileObjects; import org.junit.Before; import org.junit.Test; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import javax.tools.JavaFileObject; import static com.braisgabin.couchbaseliteorm.compiler.TestProcessors.processors; import static com.google.common.truth.Truth.ASSERT; import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource; import static com.google.testing.compile.JavaSourcesSubjectFactory.javaSources; ); } private static Path qualifiedNameToPath(String compilerPath, String sampleName, String fullyQualifiedName) { return Paths.get(compilerPath + "/../source-samples/" + sampleName + "/src/main/java/" + fullyQualifiedName.replaceAll("\\.", "/") + ".java"); } @Before public void init() { // FIXME this is a workaround. this.compilerPath = System.getProperty("compilerProjectPath"); if (this.compilerPath == null) { this.compilerPath = "./compiler"; } } @Test public void simpleCompile() throws IOException { final String sampleName = "simple"; final JavaFileObject inputFile = getJavaFileObject(compilerPath, sampleName, "com.samples.Person"); final JavaFileObject expectedFile1 = getJavaFileObject(compilerPath, sampleName, "com.samples.Person$$Mapper"); final JavaFileObject expectedFile2 = getJavaFileObject(compilerPath, sampleName, "com.braisgabin.couchbaseliteorm.CouchbaseLiteOrmInternal"); ASSERT.about(javaSource()) .that(inputFile)
.processedWith(processors())
BraisGabin/couchbase-lite-orm
core/src/test/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmTest.java
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // }
import com.couchbase.lite.CouchbaseLiteException; import com.couchbase.lite.Document; import com.samples.Person; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; import java.util.Map; import static com.google.common.truth.Truth.ASSERT; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 9/1/15. */ @RunWith(PowerMockRunner.class) @PrepareForTest(Document.class) public class CouchbaseLiteOrmTest { @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void checkFactory() { final CouchbaseLiteOrm orm = CouchbaseLiteOrm.newInstance(); ASSERT.that(orm).isInstanceOf(CouchbaseLiteOrmInternal.class); } @Test public void checkToObject_correct() { Document document = PowerMockito.mock(Document.class); // FIXME remove PowerMockito final HashMap<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("name", "Pepe"); properties.put("age", 23); when(document.getProperties()).thenReturn(properties); CouchbaseLiteOrm orm = new CouchbaseLiteOrmInternal();
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // Path: core/src/test/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmTest.java import com.couchbase.lite.CouchbaseLiteException; import com.couchbase.lite.Document; import com.samples.Person; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; import java.util.Map; import static com.google.common.truth.Truth.ASSERT; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 9/1/15. */ @RunWith(PowerMockRunner.class) @PrepareForTest(Document.class) public class CouchbaseLiteOrmTest { @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void checkFactory() { final CouchbaseLiteOrm orm = CouchbaseLiteOrm.newInstance(); ASSERT.that(orm).isInstanceOf(CouchbaseLiteOrmInternal.class); } @Test public void checkToObject_correct() { Document document = PowerMockito.mock(Document.class); // FIXME remove PowerMockito final HashMap<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("name", "Pepe"); properties.put("age", 23); when(document.getProperties()).thenReturn(properties); CouchbaseLiteOrm orm = new CouchbaseLiteOrmInternal();
Person person = orm.toObject(document);
BraisGabin/couchbase-lite-orm
compiler/src/main/java/com/braisgabin/couchbaseliteorm/compiler/MapperEmitter.java
// Path: core/src/main/java/com/braisgabin/couchbaseliteorm/Mapper.java // public interface Mapper<T> { // // T toObject(Map<String, Object> properties); // // Map<String, Object> toProperties(T object); // }
import com.braisgabin.couchbaseliteorm.Mapper; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.annotation.processing.Filer; import static javax.lang.model.element.Modifier.PUBLIC;
package com.braisgabin.couchbaseliteorm.compiler; public class MapperEmitter extends Emitter { private final Helper helper; private final EntityModel model; public MapperEmitter(Helper helper, Filer filer, EntityModel model) throws IOException { super(filer, model.getMapper().getPackage(), model.getMapper().getName(), model.getElement()); this.helper = helper; this.model = model; } @Override protected Set<String> getImports() { final Set<String> imports = new HashSet<>(Arrays.asList( Map.class.getCanonicalName(), HashMap.class.getCanonicalName(),
// Path: core/src/main/java/com/braisgabin/couchbaseliteorm/Mapper.java // public interface Mapper<T> { // // T toObject(Map<String, Object> properties); // // Map<String, Object> toProperties(T object); // } // Path: compiler/src/main/java/com/braisgabin/couchbaseliteorm/compiler/MapperEmitter.java import com.braisgabin.couchbaseliteorm.Mapper; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.annotation.processing.Filer; import static javax.lang.model.element.Modifier.PUBLIC; package com.braisgabin.couchbaseliteorm.compiler; public class MapperEmitter extends Emitter { private final Helper helper; private final EntityModel model; public MapperEmitter(Helper helper, Filer filer, EntityModel model) throws IOException { super(filer, model.getMapper().getPackage(), model.getMapper().getName(), model.getElement()); this.helper = helper; this.model = model; } @Override protected Set<String> getImports() { final Set<String> imports = new HashSet<>(Arrays.asList( Map.class.getCanonicalName(), HashMap.class.getCanonicalName(),
Mapper.class.getCanonicalName()
BraisGabin/couchbase-lite-orm
source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // }
import com.samples.Person; import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() {
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // } // Path: source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java import com.samples.Person; import com.samples.Person$$Mapper; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() {
final Person$$Mapper personMapper = new Person$$Mapper();
BraisGabin/couchbase-lite-orm
source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // }
import com.samples.Person; import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Person$$Mapper personMapper = new Person$$Mapper();
// Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // } // Path: source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java import com.samples.Person; import com.samples.Person$$Mapper; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Person$$Mapper personMapper = new Person$$Mapper();
registerType("person", Person.class, personMapper);
BraisGabin/couchbase-lite-orm
source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // }
import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() {
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // } // Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() {
final Address$$Mapper addressMapper = new Address$$Mapper();
BraisGabin/couchbase-lite-orm
source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // }
import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Address$$Mapper addressMapper = new Address$$Mapper();
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // } // Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Address$$Mapper addressMapper = new Address$$Mapper();
final Person$$Mapper personMapper = new Person$$Mapper();
BraisGabin/couchbase-lite-orm
source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // }
import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Address$$Mapper addressMapper = new Address$$Mapper(); final Person$$Mapper personMapper = new Person$$Mapper(); personMapper.addressMapper = addressMapper;
// Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java // public class Address$$Mapper implements Mapper<Address> { // // @Override // public Address toObject(Map<String, Object> properties) { // final Address object = new Address(); // object.street = (String) properties.get("street"); // if (object.street == null && !properties.containsKey("street")) { // throw new IllegalStateException("The property \"street\" is not set."); // } // object.number = (String) properties.get("number"); // if (object.number == null && !properties.containsKey("number")) { // throw new IllegalStateException("The property \"number\" is not set."); // } // return object; // } // // @Override // public Map<String, Object> toProperties(Address object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("street", object.street); // properties.put("number", object.number); // return properties; // } // } // // Path: source-samples/simple/src/main/java/com/samples/Person.java // @Entity("person") // public class Person { // // @Field("name") // String name; // // @Field("age") // int age; // // public Person() { // } // // public Person(String name, Integer age) { // this.name = name; // this.age = age; // } // // public String getName() { // return name; // } // // public Integer getAge() { // return age; // } // } // // Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java // public class Person$$Mapper implements Mapper<Person> { // public Address$$Mapper addressMapper; // // @Override // public Person toObject(Map<String, Object> properties) { // final Person object = new Person(); // if (properties.get("address") != null) { // object.address = addressMapper.toObject((Map<String, Object>) properties.get("address")); // } else if (!properties.containsKey("address")) { // throw new IllegalStateException("The property \"address\" is not set."); // } else { // object.address = null; // } // return object; // } // // @Override // public Map<String, Object> toProperties(Person object) { // final Map<String, Object> properties = new HashMap<>(); // properties.put("type", "person"); // properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address)); // return properties; // } // } // Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java import com.samples.Address$$Mapper; import com.samples.Person; import com.samples.Person$$Mapper; package com.braisgabin.couchbaseliteorm; /** * Created by brais on 7/1/15. */ class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm { CouchbaseLiteOrmInternal() { final Address$$Mapper addressMapper = new Address$$Mapper(); final Person$$Mapper personMapper = new Person$$Mapper(); personMapper.addressMapper = addressMapper;
registerType("person", Person.class, personMapper);
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/activity/RankActivity.java
// Path: app/src/main/java/studio/androiddev/puzzle/model/Record.java // public class Record extends BmobObject implements Serializable { // String type; // String time; // String phoneNum; // String update_time; // String pic_url; // String nickname; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public String getPhoneNum() { // return phoneNum; // } // // public void setPhoneNum(String phoneNum) { // this.phoneNum = phoneNum; // } // // public String getUpdate_time() { // return update_time; // } // // public void setUpdate_time(String update_time) { // this.update_time = update_time; // } // // public String getPic_url() { // return pic_url; // } // // public void setPic_url(String pic_url) { // this.pic_url = pic_url; // } // // public String getNickname() { // return nickname; // } // // public void setNickname(String nickname) { // this.nickname = nickname; // } // // @Override // public String toString() { // return "Record{" + // "type='" + type + '\'' + // ", time='" + time + '\'' + // ", phoneNum='" + phoneNum + '\'' + // ", update_time='" + update_time + '\'' + // ", pic_url='" + pic_url + '\'' + // ", nickname='" + nickname + '\'' + // '}'; // } // }
import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.model.Record;
package studio.androiddev.puzzle.activity; public class RankActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; ListView mlv_rank;
// Path: app/src/main/java/studio/androiddev/puzzle/model/Record.java // public class Record extends BmobObject implements Serializable { // String type; // String time; // String phoneNum; // String update_time; // String pic_url; // String nickname; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getTime() { // return time; // } // // public void setTime(String time) { // this.time = time; // } // // public String getPhoneNum() { // return phoneNum; // } // // public void setPhoneNum(String phoneNum) { // this.phoneNum = phoneNum; // } // // public String getUpdate_time() { // return update_time; // } // // public void setUpdate_time(String update_time) { // this.update_time = update_time; // } // // public String getPic_url() { // return pic_url; // } // // public void setPic_url(String pic_url) { // this.pic_url = pic_url; // } // // public String getNickname() { // return nickname; // } // // public void setNickname(String nickname) { // this.nickname = nickname; // } // // @Override // public String toString() { // return "Record{" + // "type='" + type + '\'' + // ", time='" + time + '\'' + // ", phoneNum='" + phoneNum + '\'' + // ", update_time='" + update_time + '\'' + // ", pic_url='" + pic_url + '\'' + // ", nickname='" + nickname + '\'' + // '}'; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/activity/RankActivity.java import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.model.Record; package studio.androiddev.puzzle.activity; public class RankActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; ListView mlv_rank;
List<Record> mRecSet;
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/activity/ChoosePicActivity.java
// Path: app/src/main/java/studio/androiddev/puzzle/adapter/ChoosePicGridViewAdapter.java // public class ChoosePicGridViewAdapter extends ArrayAdapter<Integer> { // // int resourceId; // // public ChoosePicGridViewAdapter(Context context, int resourceId){ // super(context, resourceId); // this.resourceId = resourceId; // } // // @Override // public int getCount(){ // return ChoosePicActivity.icons.length; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent){ // ViewHolder holder = null; // View view; // if(convertView == null){ // view = LayoutInflater.from(getContext()).inflate(resourceId, null); // holder = new ViewHolder(); // holder.imageView = (ImageView) view.findViewById(R.id.imageItem); // view.setTag(holder); // }else{ // view = convertView; // holder = (ViewHolder) view.getTag(); // } // // holder.imageView.setImageBitmap(BitmapUtils.decodeSampledBitmapFromResources( // getContext().getResources(), // ChoosePicActivity.icons[position], // 300, // 300 // )); // // return view; // } // // class ViewHolder{ // ImageView imageView; // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import butterknife.Bind; import butterknife.ButterKnife; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.adapter.ChoosePicGridViewAdapter;
package studio.androiddev.puzzle.activity; public class ChoosePicActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; @Bind(R.id.picContainer) GridView picContainer; public static final int [] icons={ R.drawable.default1, R.drawable.default2, R.drawable.default3, R.drawable.default4, R.drawable.default5, R.drawable.default6 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_pic); ButterKnife.bind(this); setSupportActionBar(toolbar); initView(); } private void initView() { toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
// Path: app/src/main/java/studio/androiddev/puzzle/adapter/ChoosePicGridViewAdapter.java // public class ChoosePicGridViewAdapter extends ArrayAdapter<Integer> { // // int resourceId; // // public ChoosePicGridViewAdapter(Context context, int resourceId){ // super(context, resourceId); // this.resourceId = resourceId; // } // // @Override // public int getCount(){ // return ChoosePicActivity.icons.length; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent){ // ViewHolder holder = null; // View view; // if(convertView == null){ // view = LayoutInflater.from(getContext()).inflate(resourceId, null); // holder = new ViewHolder(); // holder.imageView = (ImageView) view.findViewById(R.id.imageItem); // view.setTag(holder); // }else{ // view = convertView; // holder = (ViewHolder) view.getTag(); // } // // holder.imageView.setImageBitmap(BitmapUtils.decodeSampledBitmapFromResources( // getContext().getResources(), // ChoosePicActivity.icons[position], // 300, // 300 // )); // // return view; // } // // class ViewHolder{ // ImageView imageView; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/activity/ChoosePicActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import butterknife.Bind; import butterknife.ButterKnife; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.adapter.ChoosePicGridViewAdapter; package studio.androiddev.puzzle.activity; public class ChoosePicActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; @Bind(R.id.picContainer) GridView picContainer; public static final int [] icons={ R.drawable.default1, R.drawable.default2, R.drawable.default3, R.drawable.default4, R.drawable.default5, R.drawable.default6 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_pic); ButterKnife.bind(this); setSupportActionBar(toolbar); initView(); } private void initView() { toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
picContainer.setAdapter(new ChoosePicGridViewAdapter(ChoosePicActivity.this, R.layout.choose_pic_gridview_item));
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/activity/SettingActivity.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java // public class StaticValue { // public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35"; // // public static final String SP_NAME = "puzzle_sp"; // public static final String SP_LEVEL = "level"; // }
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.utils.StaticValue;
package studio.androiddev.puzzle.activity; public class SettingActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; @Bind(R.id.levelChooseButton) Button levelChooseButton; @Bind(R.id.buttonShare) ImageButton buttonShare; private int choosedLevel = 0; final int[] levels = { R.string.setting_level_3, R.string.setting_level_4, R.string.setting_level_5, R.string.setting_level_6}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); ButterKnife.bind(this); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java // public class StaticValue { // public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35"; // // public static final String SP_NAME = "puzzle_sp"; // public static final String SP_LEVEL = "level"; // } // Path: app/src/main/java/studio/androiddev/puzzle/activity/SettingActivity.java import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.utils.StaticValue; package studio.androiddev.puzzle.activity; public class SettingActivity extends BaseActivity { @Bind(R.id.toolbar) Toolbar toolbar; @Bind(R.id.levelChooseButton) Button levelChooseButton; @Bind(R.id.buttonShare) ImageButton buttonShare; private int choosedLevel = 0; final int[] levels = { R.string.setting_level_3, R.string.setting_level_4, R.string.setting_level_5, R.string.setting_level_6}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); ButterKnife.bind(this); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
levelChooseButton.setText(getString(levels[PuzzleApplication.getLevel() - 3]));
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/activity/SettingActivity.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java // public class StaticValue { // public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35"; // // public static final String SP_NAME = "puzzle_sp"; // public static final String SP_LEVEL = "level"; // }
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.utils.StaticValue;
defaultWhich = i; } } builder.setSingleChoiceItems(levels, defaultWhich, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { choosedLevel = which; } }); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { levelChooseButton.setText(levels[choosedLevel]); changeLevel(); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); } private void changeLevel() { int level = choosedLevel + 3;
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/StaticValue.java // public class StaticValue { // public static String bmobId = "284420dcdca2ba4dbb2f1b2bb463fb35"; // // public static final String SP_NAME = "puzzle_sp"; // public static final String SP_LEVEL = "level"; // } // Path: app/src/main/java/studio/androiddev/puzzle/activity/SettingActivity.java import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import butterknife.OnClick; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.R; import studio.androiddev.puzzle.utils.StaticValue; defaultWhich = i; } } builder.setSingleChoiceItems(levels, defaultWhich, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { choosedLevel = which; } }); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { levelChooseButton.setText(levels[choosedLevel]); changeLevel(); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); } private void changeLevel() { int level = choosedLevel + 3;
SharedPreferences.Editor editor = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE).edit();
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // }
import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil;
* @return 判断结果 */ public boolean judgeDrag(int i, int x, int y){ RectF rect = getRectF(i); return rect.contains(x, y); } /** * 根据拼块下标计算拼块实际占据的方形大小 * @param i 拼块下标 * @return 拼块实际占据的方形大小 */ private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish();
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil; * @return 判断结果 */ public boolean judgeDrag(int i, int x, int y){ RectF rect = getRectF(i); return rect.contains(x, y); } /** * 根据拼块下标计算拼块实际占据的方形大小 * @param i 拼块下标 * @return 拼块实际占据的方形大小 */ private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish();
EventBus.getDefault().post(new PieceMoveSuccessEvent(i));
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // }
import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil;
RectF rect = getRectF(i); return rect.contains(x, y); } /** * 根据拼块下标计算拼块实际占据的方形大小 * @param i 拼块下标 * @return 拼块实际占据的方形大小 */ private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil; RectF rect = getRectF(i); return rect.contains(x, y); } /** * 根据拼块下标计算拼块实际占据的方形大小 * @param i 拼块下标 * @return 拼块实际占据的方形大小 */ private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){
EventBus.getDefault().post(new GameSuccessEvent());
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // }
import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil;
private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){ EventBus.getDefault().post(new GameSuccessEvent()); } } /** * 根据拼盘大小和游戏难度初始化基本遮罩拼块 */ private void initMask(){
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil; private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){ EventBus.getDefault().post(new GameSuccessEvent()); } } /** * 根据拼盘大小和游戏难度初始化基本遮罩拼块 */ private void initMask(){
rectWidth = DensityUtil.dip2px(PuzzleApplication.getAppContext(), (float) DISH_WIDTH / mLevel);
FreedomZZQ/Puzzle-Android
app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // }
import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil;
private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){ EventBus.getDefault().post(new GameSuccessEvent()); } } /** * 根据拼盘大小和游戏难度初始化基本遮罩拼块 */ private void initMask(){
// Path: app/src/main/java/studio/androiddev/puzzle/PuzzleApplication.java // public class PuzzleApplication extends Application{ // // private static Context mContext; // // private static User mUser; // // private static DishManager dm; // // public static int getLevel() { // return level; // } // // public static void setLevel(int level) { // if(level < 3) return; // PuzzleApplication.level = level; // initDishManager(); // } // // private static int level = 4; // // @Override // public void onCreate(){ // super.onCreate(); // LeakCanary.install(this); // Bmob.initialize(this, StaticValue.bmobId); // if(mContext == null) mContext = getApplicationContext(); // SharedPreferences pref = getSharedPreferences(StaticValue.SP_NAME, MODE_PRIVATE); // setLevel(pref.getInt(StaticValue.SP_LEVEL, 4)); // } // // public static User getmUser() { // return mUser; // } // // public static void setmUser(User mUser) { // PuzzleApplication.mUser = mUser; // } // // public static Context getAppContext(){ // return mContext; // } // // public static void initDishManager(){ // dm = new DishManager(level); // } // // public static DishManager getDishManager(){ // return dm; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/GameSuccessEvent.java // public class GameSuccessEvent { // } // // Path: app/src/main/java/studio/androiddev/puzzle/event/PieceMoveSuccessEvent.java // public class PieceMoveSuccessEvent { // // private int index; // public PieceMoveSuccessEvent(int index){ // this.index = index; // } // // public int getIndex(){ // return index; // } // } // // Path: app/src/main/java/studio/androiddev/puzzle/utils/DensityUtil.java // public class DensityUtil { // // /** // * 根据手机的分辨率从 dp 的单位 转成为 px(像素) // */ // public static int dip2px(Context context, float dpValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dpValue * scale + 0.5f); // } // // /** // * 根据手机的分辨率从 px(像素) 的单位 转成为 dp // */ // public static int px2dip(Context context, float pxValue) { // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (pxValue / scale + 0.5f); // } // // public static float getScale(Context context){ // return context.getResources().getDisplayMetrics().density; // } // } // Path: app/src/main/java/studio/androiddev/puzzle/dish/DishManager.java import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.RectF; import android.util.Log; import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import org.greenrobot.eventbus.EventBus; import studio.androiddev.puzzle.PuzzleApplication; import studio.androiddev.puzzle.event.GameSuccessEvent; import studio.androiddev.puzzle.event.PieceMoveSuccessEvent; import studio.androiddev.puzzle.utils.DensityUtil; private RectF getRectF(int i){ return new RectF( (i % mLevel) * rectWidth, (i / mLevel) * rectHeight, (i % mLevel + 1) * rectWidth, (i / mLevel + 1) * rectHeight); } /** * 当玩家将拼块移动到正确位置时调用,更新拼盘显示状态 * @param i 正确的拼块下标 */ public void updatePiece(int i){ if(i < 0 || i > mLevel * mLevel) return; mIndex[i] = true; refreshDish(); EventBus.getDefault().post(new PieceMoveSuccessEvent(i)); mLeftSize--; if(mLeftSize == 0){ EventBus.getDefault().post(new GameSuccessEvent()); } } /** * 根据拼盘大小和游戏难度初始化基本遮罩拼块 */ private void initMask(){
rectWidth = DensityUtil.dip2px(PuzzleApplication.getAppContext(), (float) DISH_WIDTH / mLevel);
eMoflon/benchmarx
examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/ibextgg/IBeXTGGFamiliesToPersons.java
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // }
import java.io.IOException; import java.util.function.Consumer; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.emoflon.ibex.tgg.run.ibextggfamiliestopersons.SYNC_App; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister;
} catch (IOException e) { e.printStackTrace(); } } @Override public void performAndPropagateTargetEdit(Consumer<PersonRegister> edit) { // Adapt target model PersonRegister o = (PersonRegister) sync.getTargetResource().getContents().get(0); edit.accept(o); // Invoke sync try { sync.backward(); } catch (IOException e) { e.printStackTrace(); } } @Override public void performIdleSourceEdit(Consumer<FamilyRegister> edit) { performAndPropagateSourceEdit(edit); } @Override public void performIdleTargetEdit(Consumer<PersonRegister> edit) { performAndPropagateTargetEdit(edit); } @Override
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // } // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/ibextgg/IBeXTGGFamiliesToPersons.java import java.io.IOException; import java.util.function.Consumer; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.emoflon.ibex.tgg.run.ibextggfamiliestopersons.SYNC_App; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; } catch (IOException e) { e.printStackTrace(); } } @Override public void performAndPropagateTargetEdit(Consumer<PersonRegister> edit) { // Adapt target model PersonRegister o = (PersonRegister) sync.getTargetResource().getContents().get(0); edit.accept(o); // Invoke sync try { sync.backward(); } catch (IOException e) { e.printStackTrace(); } } @Override public void performIdleSourceEdit(Consumer<FamilyRegister> edit) { performAndPropagateSourceEdit(edit); } @Override public void performIdleTargetEdit(Consumer<PersonRegister> edit) { performAndPropagateTargetEdit(edit); } @Override
public void setConfigurator(Configurator<Decisions> configurator) {
eMoflon/benchmarx
examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/factories/ibextgggantt2cpm/UserDefinedRuntimeTGGAttrConstraintFactory.java
// Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_notADependencyViaNamingConvention.java // public class UserDefined_notADependencyViaNamingConvention extends RuntimeTGGAttributeConstraint { // // /** // * Constraint notADependencyViaNamingConvention(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -NOTADEPENDENCYVIANAMINGCONVENTION- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "B": // String name = (String) v0.getValue(); // setSatisfied(!name.contains("->")); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_setCounter.java // public class UserDefined_setCounter extends RuntimeTGGAttributeConstraint { // // private static int nextNumber = 1; // // /** // * Constraint setCounter(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -SETCOUNTER- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "F": // v0.bindToValue(nextNumber++); // setSatisfied(true); // break; // case "B": // setSatisfied(true); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // }
import java.util.HashMap; import java.util.HashSet; import org.emoflon.ibex.tgg.operational.csp.constraints.factories.RuntimeTGGAttrConstraintFactory; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_notADependencyViaNamingConvention; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_setCounter;
package org.emoflon.ibex.tgg.operational.csp.constraints.factories.ibextgggantt2cpm; public class UserDefinedRuntimeTGGAttrConstraintFactory extends RuntimeTGGAttrConstraintFactory { public UserDefinedRuntimeTGGAttrConstraintFactory() { super(); } @Override protected void initialize() { creators = new HashMap<>();
// Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_notADependencyViaNamingConvention.java // public class UserDefined_notADependencyViaNamingConvention extends RuntimeTGGAttributeConstraint { // // /** // * Constraint notADependencyViaNamingConvention(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -NOTADEPENDENCYVIANAMINGCONVENTION- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "B": // String name = (String) v0.getValue(); // setSatisfied(!name.contains("->")); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_setCounter.java // public class UserDefined_setCounter extends RuntimeTGGAttributeConstraint { // // private static int nextNumber = 1; // // /** // * Constraint setCounter(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -SETCOUNTER- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "F": // v0.bindToValue(nextNumber++); // setSatisfied(true); // break; // case "B": // setSatisfied(true); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/factories/ibextgggantt2cpm/UserDefinedRuntimeTGGAttrConstraintFactory.java import java.util.HashMap; import java.util.HashSet; import org.emoflon.ibex.tgg.operational.csp.constraints.factories.RuntimeTGGAttrConstraintFactory; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_notADependencyViaNamingConvention; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_setCounter; package org.emoflon.ibex.tgg.operational.csp.constraints.factories.ibextgggantt2cpm; public class UserDefinedRuntimeTGGAttrConstraintFactory extends RuntimeTGGAttrConstraintFactory { public UserDefinedRuntimeTGGAttrConstraintFactory() { super(); } @Override protected void initialize() { creators = new HashMap<>();
creators.put("notADependencyViaNamingConvention", () -> new UserDefined_notADependencyViaNamingConvention());
eMoflon/benchmarx
examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/factories/ibextgggantt2cpm/UserDefinedRuntimeTGGAttrConstraintFactory.java
// Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_notADependencyViaNamingConvention.java // public class UserDefined_notADependencyViaNamingConvention extends RuntimeTGGAttributeConstraint { // // /** // * Constraint notADependencyViaNamingConvention(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -NOTADEPENDENCYVIANAMINGCONVENTION- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "B": // String name = (String) v0.getValue(); // setSatisfied(!name.contains("->")); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_setCounter.java // public class UserDefined_setCounter extends RuntimeTGGAttributeConstraint { // // private static int nextNumber = 1; // // /** // * Constraint setCounter(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -SETCOUNTER- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "F": // v0.bindToValue(nextNumber++); // setSatisfied(true); // break; // case "B": // setSatisfied(true); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // }
import java.util.HashMap; import java.util.HashSet; import org.emoflon.ibex.tgg.operational.csp.constraints.factories.RuntimeTGGAttrConstraintFactory; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_notADependencyViaNamingConvention; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_setCounter;
package org.emoflon.ibex.tgg.operational.csp.constraints.factories.ibextgggantt2cpm; public class UserDefinedRuntimeTGGAttrConstraintFactory extends RuntimeTGGAttrConstraintFactory { public UserDefinedRuntimeTGGAttrConstraintFactory() { super(); } @Override protected void initialize() { creators = new HashMap<>(); creators.put("notADependencyViaNamingConvention", () -> new UserDefined_notADependencyViaNamingConvention());
// Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_notADependencyViaNamingConvention.java // public class UserDefined_notADependencyViaNamingConvention extends RuntimeTGGAttributeConstraint { // // /** // * Constraint notADependencyViaNamingConvention(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -NOTADEPENDENCYVIANAMINGCONVENTION- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "B": // String name = (String) v0.getValue(); // setSatisfied(!name.contains("->")); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/custom/ibextgggantt2cpm/UserDefined_setCounter.java // public class UserDefined_setCounter extends RuntimeTGGAttributeConstraint { // // private static int nextNumber = 1; // // /** // * Constraint setCounter(v0) // * // * @see TGGLanguage.csp.impl.ConstraintImpl#solve() // */ // @Override // public void solve() { // if (variables.size() != 1) // throw new RuntimeException("The CSP -SETCOUNTER- needs exactly 1 variables"); // // RuntimeTGGAttributeConstraintVariable v0 = variables.get(0); // String bindingStates = getBindingStates(v0); // // switch (bindingStates) { // case "F": // v0.bindToValue(nextNumber++); // setSatisfied(true); // break; // case "B": // setSatisfied(true); // break; // default: // throw new UnsupportedOperationException( // "This case in the constraint has not been implemented yet: " + bindingStates); // } // } // } // Path: examples/gantttocpm/implementationArtefacts/emoflon/IBeXTGGGantt2CPM/src/org/emoflon/ibex/tgg/operational/csp/constraints/factories/ibextgggantt2cpm/UserDefinedRuntimeTGGAttrConstraintFactory.java import java.util.HashMap; import java.util.HashSet; import org.emoflon.ibex.tgg.operational.csp.constraints.factories.RuntimeTGGAttrConstraintFactory; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_notADependencyViaNamingConvention; import org.emoflon.ibex.tgg.operational.csp.constraints.custom.ibextgggantt2cpm.UserDefined_setCounter; package org.emoflon.ibex.tgg.operational.csp.constraints.factories.ibextgggantt2cpm; public class UserDefinedRuntimeTGGAttrConstraintFactory extends RuntimeTGGAttrConstraintFactory { public UserDefinedRuntimeTGGAttrConstraintFactory() { super(); } @Override protected void initialize() { creators = new HashMap<>(); creators.put("notADependencyViaNamingConvention", () -> new UserDefined_notADependencyViaNamingConvention());
creators.put("setCounter", () -> new UserDefined_setCounter());
eMoflon/benchmarx
examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/funnyqt/FunnyQTFamiliesToPerson.java
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/Comparator.java // public interface Comparator<M> { // // /** // * Compare two models and throw an exception if they are not to be // * considered identical. // * // * @param expected // * The expected model // * @param actual // * The actual model // * @throws AssertionFailedError // * Expected to throw assertion failed errors via {@link Assert} // * if the models are not identical does not hold. // */ // void assertEquals(M expected, M actual); // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // }
import java.io.File; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.emf.Comparator; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import clojure.java.api.Clojure; import clojure.lang.IFn; import clojure.lang.Keyword;
package org.benchmarx.examples.familiestopersons.implementations.funnyqt; /** * Driver for the FunnyQT solution. * * @see <a href"https://github.com/tsdh/ttc17-families2persons-bx">The soution's * source code</a> * * @author Dr. Tassilo Horn &lt;tsdh@gnu.org&gt; */ public class FunnyQTFamiliesToPerson extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private static final String RESULTPATH = "results/funnyqt"; private Resource srcModel; private Resource trgModel;
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/Comparator.java // public interface Comparator<M> { // // /** // * Compare two models and throw an exception if they are not to be // * considered identical. // * // * @param expected // * The expected model // * @param actual // * The actual model // * @throws AssertionFailedError // * Expected to throw assertion failed errors via {@link Assert} // * if the models are not identical does not hold. // */ // void assertEquals(M expected, M actual); // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // } // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/funnyqt/FunnyQTFamiliesToPerson.java import java.io.File; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.emf.Comparator; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import clojure.java.api.Clojure; import clojure.lang.IFn; import clojure.lang.Keyword; package org.benchmarx.examples.familiestopersons.implementations.funnyqt; /** * Driver for the FunnyQT solution. * * @see <a href"https://github.com/tsdh/ttc17-families2persons-bx">The soution's * source code</a> * * @author Dr. Tassilo Horn &lt;tsdh@gnu.org&gt; */ public class FunnyQTFamiliesToPerson extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private static final String RESULTPATH = "results/funnyqt"; private Resource srcModel; private Resource trgModel;
private Configurator<Decisions> configurator;
eMoflon/benchmarx
examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/bxtend/UbtXtendFamiliesToPersons.java
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // }
import java.io.IOException; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import bitrafo.eval.familyperson.rules.decisions.ConfigurableTargetToSourceDecision; import bitrafo.eval.familyperson.rules.Family2PersonTransformation;
package org.benchmarx.examples.familiestopersons.implementations.bxtend; public class UbtXtendFamiliesToPersons extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private ResourceSet set = new ResourceSetImpl(); private Resource source; private Resource target; private Resource corr; private Family2PersonTransformation f2pt;
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // } // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/bxtend/UbtXtendFamiliesToPersons.java import java.io.IOException; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import bitrafo.eval.familyperson.rules.decisions.ConfigurableTargetToSourceDecision; import bitrafo.eval.familyperson.rules.Family2PersonTransformation; package org.benchmarx.examples.familiestopersons.implementations.bxtend; public class UbtXtendFamiliesToPersons extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private ResourceSet set = new ResourceSetImpl(); private Resource source; private Resource target; private Resource corr; private Family2PersonTransformation f2pt;
private Configurator<Decisions> conf;
eMoflon/benchmarx
examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/jtl/JTLFamiliesToPersons.java
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // }
import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import Persons.PersonsFactory; import jtl.launcher.Launcher;
package org.benchmarx.examples.familiestopersons.implementations.jtl; public class JTLFamiliesToPersons extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private static int testNumber = 0; private static final String SOURCEPATH = "results/jtl/"; private static final String TARGETPATH = SOURCEPATH + "target/"; private ResourceSet resourceSet; private Map<String, Object >globalPackageRegistry; private FamilyRegister familiesModel; private PersonRegister personsModel; private static final String artefactsPath = "../implementationArtefacts/jtl/"; private static final String transformation = artefactsPath + "Families2Persons.dl"; private static final String familiesMetamodel = "../metamodels/Families/model/Families.ecore"; private static final String personsMetamodel = "../metamodels/Persons/model/Persons.ecore"; private List<String> additionalConstraints;
// Path: core/Benchmarx/src/org/benchmarx/Configurator.java // public class Configurator<D> { // // private Map<D, Boolean> decisions = new HashMap<>(); // // /** // * Invoked to register b for decision d as part of a setup. // * // * @param d // * The decision to be registered. // * @param b // * The value to be returned if this decision is requested. // * @return // */ // public Configurator<D> makeDecision(D d, boolean b) { // decisions.put(d, b); // return this; // } // // /** // * Invoked by a {@link BXTool} during propagation to retrieve a yes or no // * for the passed decision. // * // * @param decision // * The decision for which a yes or no is requested. // * @return Returns a yes or no for the decision based on previously // * registered values in {@link #makeDecision(Object, boolean)}. // * @throws IllegalArgumentException // * A runtime exception if there is no registered value for the // * requested decision. This can either indicate a faulty update // * policy or an expected decision request from the // * {@link BXTool} under test. // */ // public boolean decide(D decision) { // if (decisions.containsKey(decision)) // return decisions.get(decision); // else // throw new IllegalArgumentException("I don't know how to handle: " + decision); // } // } // // Path: core/Benchmarx/src/org/benchmarx/emf/BXToolForEMF.java // public abstract class BXToolForEMF<S, T, D> implements BXTool<S, T, D> { // // private Comparator<S> src; // private Comparator<T> trg; // // /** // * Requires a {@link Comparator} for each metamodel, which is used for // * asserting pre- and postconditions. // * // * @param src // * A {@link Comparator} for source models // * @param trg // * A {@link Comparator} for target models // */ // public BXToolForEMF(Comparator<S> src, Comparator<T> trg){ // this.src = src; // this.trg = trg; // } // // /** // * Return the internally stored source model of the {@link BXTool} // * // * @return An EMF-based source model // */ // public abstract S getSourceModel(); // // /** // * See {@link #getSourceModel()} // */ // public abstract T getTargetModel(); // // /** // * Prompt the tool to save the current state of all its models for debugging // * purposes. The tool decides what to save and where to save it. // * // * @param name // * A label that can be used to form the names of the models (for // * easy identification). // */ // public abstract void saveModels(String name); // // private void assertModels(S source, T target) { // src.assertEquals(source, getSourceModel()); // trg.assertEquals(target, getTargetModel()); // } // // @Override // public void assertPostcondition(S source, T target){ // assertModels(source, target); // } // // @Override // public void assertPrecondition(S source, T target){ // assertModels(source, target); // } // // @Override // public String toString() { // return getName(); // } // } // // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/testsuite/Decisions.java // public enum Decisions { // PREFER_CREATING_PARENT_TO_CHILD, // PREFER_EXISTING_FAMILY_TO_NEW // } // Path: examples/familiestopersons/BenchmarxFamiliesToPersons/src/org/benchmarx/examples/familiestopersons/implementations/jtl/JTLFamiliesToPersons.java import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; import org.benchmarx.Configurator; import org.benchmarx.emf.BXToolForEMF; import org.benchmarx.examples.familiestopersons.testsuite.Decisions; import org.benchmarx.families.core.FamiliesComparator; import org.benchmarx.persons.core.PersonsComparator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import Families.FamiliesFactory; import Families.FamilyRegister; import Persons.PersonRegister; import Persons.PersonsFactory; import jtl.launcher.Launcher; package org.benchmarx.examples.familiestopersons.implementations.jtl; public class JTLFamiliesToPersons extends BXToolForEMF<FamilyRegister, PersonRegister, Decisions> { private static int testNumber = 0; private static final String SOURCEPATH = "results/jtl/"; private static final String TARGETPATH = SOURCEPATH + "target/"; private ResourceSet resourceSet; private Map<String, Object >globalPackageRegistry; private FamilyRegister familiesModel; private PersonRegister personsModel; private static final String artefactsPath = "../implementationArtefacts/jtl/"; private static final String transformation = artefactsPath + "Families2Persons.dl"; private static final String familiesMetamodel = "../metamodels/Families/model/Families.ecore"; private static final String personsMetamodel = "../metamodels/Persons/model/Persons.ecore"; private List<String> additionalConstraints;
private Configurator<Decisions> configurator;
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/KnownTypeAdaptersExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class KnownTypeAdaptersExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/KnownTypeAdaptersExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class KnownTypeAdaptersExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(KnownTypeAdaptersExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModelGeneric1Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelGeneric1Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModelGeneric1Test.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelGeneric1Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelGeneric1.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/DynamicallyTypedModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link DynamicallyTypedModel}. */ public class DynamicallyTypedModelTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/DynamicallyTypedModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link DynamicallyTypedModel}. */ public class DynamicallyTypedModelTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(DynamicallyTypedModel.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; public class NativeJavaModelTest { @Test public void typeAdapterWasGenerated_NativeJavaModel() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; public class NativeJavaModelTest { @Test public void typeAdapterWasGenerated_NativeJavaModel() throws Exception {
Utils.verifyTypeAdapterGeneration(NativeJavaModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/EnumExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class EnumExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/EnumExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class EnumExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(EnumExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/WildcardModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import com.vimeo.stag.UseStag; import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; @UseStag public class WildcardModelTest { @Test public void typeAdapterWasGenerated_WildcardModel() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/WildcardModelTest.java import com.vimeo.stag.UseStag; import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; @UseStag public class WildcardModelTest { @Test public void typeAdapterWasGenerated_WildcardModel() throws Exception {
Utils.verifyTypeAdapterGeneration(WildcardModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NoUseStagAnnotationTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 1/30/17. */ public class NoUseStagAnnotationTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NoUseStagAnnotationTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 1/30/17. */ public class NoUseStagAnnotationTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(NoUseStagAnnotation.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionNoneExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionNoneExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionNoneExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionNoneExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(FieldOptionNoneExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/AlternateNameModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class AlternateNameModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/AlternateNameModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class AlternateNameModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(AlternateNameModel.class);
vimeo/stag-java
sample/src/main/java/com/vimeo/sample/network/NetworkRequest.java
// Path: sample/src/main/java/com/vimeo/sample/model/DateParser.java // public class DateParser extends TypeAdapter<Date> { // // private static final SimpleDateFormat dateFormat = // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.ENGLISH); // // @Override // public void write(JsonWriter out, Date value) throws IOException { // out.value(dateFormat.format(value)); // } // // @Override // public Date read(JsonReader in) throws IOException { // try { // return dateFormat.parse(in.nextString()); // } catch (ParseException e) { // throw new IOException("Date parsing failed", e); // } // } // } // // Path: sample/src/main/java/com/vimeo/sample/model/Video.java // @UseStag // public class Video { // // @SerializedName("user") // public User mUser; // // @SerializedName("link") // public String mLink; // // @SerializedName("name") // public String mName; // // @SerializedName("created_time") // public Date mCreatedTime; // // @SerializedName("stats") // public Stats mStats; // // @Override // public String toString() { // return "user: { " + (mUser != null ? mUser.toString() : null) + " }\nlink: " + mLink + "\nname: " + // mName + "\ncreated_time: " + mCreatedTime + "\nstats: { " + // (mStats != null ? mStats.toString() : null) + " }"; // } // }
import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.TypeAdapter; import com.vimeo.sample.model.DateParser; import com.vimeo.sample.model.Video; import com.vimeo.sample.model.VideoList; import com.vimeo.sample.model.VideoList$TypeAdapter; import com.vimeo.sample.stag.generated.Stag; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Executors;
/* * The MIT License (MIT) * <p/> * Copyright (c) 2016 Vimeo * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.vimeo.sample.network; public final class NetworkRequest { private static final String TAG = "NetworkRequest"; public interface Callback {
// Path: sample/src/main/java/com/vimeo/sample/model/DateParser.java // public class DateParser extends TypeAdapter<Date> { // // private static final SimpleDateFormat dateFormat = // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.ENGLISH); // // @Override // public void write(JsonWriter out, Date value) throws IOException { // out.value(dateFormat.format(value)); // } // // @Override // public Date read(JsonReader in) throws IOException { // try { // return dateFormat.parse(in.nextString()); // } catch (ParseException e) { // throw new IOException("Date parsing failed", e); // } // } // } // // Path: sample/src/main/java/com/vimeo/sample/model/Video.java // @UseStag // public class Video { // // @SerializedName("user") // public User mUser; // // @SerializedName("link") // public String mLink; // // @SerializedName("name") // public String mName; // // @SerializedName("created_time") // public Date mCreatedTime; // // @SerializedName("stats") // public Stats mStats; // // @Override // public String toString() { // return "user: { " + (mUser != null ? mUser.toString() : null) + " }\nlink: " + mLink + "\nname: " + // mName + "\ncreated_time: " + mCreatedTime + "\nstats: { " + // (mStats != null ? mStats.toString() : null) + " }"; // } // } // Path: sample/src/main/java/com/vimeo/sample/network/NetworkRequest.java import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.TypeAdapter; import com.vimeo.sample.model.DateParser; import com.vimeo.sample.model.Video; import com.vimeo.sample.model.VideoList; import com.vimeo.sample.model.VideoList$TypeAdapter; import com.vimeo.sample.stag.generated.Stag; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Executors; /* * The MIT License (MIT) * <p/> * Copyright (c) 2016 Vimeo * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.vimeo.sample.network; public final class NetworkRequest { private static final String TAG = "NetworkRequest"; public interface Callback {
void onReceived(List<Video> list);
vimeo/stag-java
sample/src/main/java/com/vimeo/sample/network/NetworkRequest.java
// Path: sample/src/main/java/com/vimeo/sample/model/DateParser.java // public class DateParser extends TypeAdapter<Date> { // // private static final SimpleDateFormat dateFormat = // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.ENGLISH); // // @Override // public void write(JsonWriter out, Date value) throws IOException { // out.value(dateFormat.format(value)); // } // // @Override // public Date read(JsonReader in) throws IOException { // try { // return dateFormat.parse(in.nextString()); // } catch (ParseException e) { // throw new IOException("Date parsing failed", e); // } // } // } // // Path: sample/src/main/java/com/vimeo/sample/model/Video.java // @UseStag // public class Video { // // @SerializedName("user") // public User mUser; // // @SerializedName("link") // public String mLink; // // @SerializedName("name") // public String mName; // // @SerializedName("created_time") // public Date mCreatedTime; // // @SerializedName("stats") // public Stats mStats; // // @Override // public String toString() { // return "user: { " + (mUser != null ? mUser.toString() : null) + " }\nlink: " + mLink + "\nname: " + // mName + "\ncreated_time: " + mCreatedTime + "\nstats: { " + // (mStats != null ? mStats.toString() : null) + " }"; // } // }
import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.TypeAdapter; import com.vimeo.sample.model.DateParser; import com.vimeo.sample.model.Video; import com.vimeo.sample.model.VideoList; import com.vimeo.sample.model.VideoList$TypeAdapter; import com.vimeo.sample.stag.generated.Stag; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Executors;
void cancelRequest() { mCallback = null; cancel(true); } @Override protected List<Video> doInBackground(Void... params) { String url = "https://api.vimeo.com/channels/staffpicks/videos"; String token = "bearer b8e31bd89ba1ee093dc6ab0f863db1bd"; ArrayList<Video> videos = new ArrayList<>(); StringBuilder builder = new StringBuilder(); BufferedReader stream = null; try { URL uri = new URL(url); HttpURLConnection connection = (HttpURLConnection) uri.openConnection(); connection.setRequestProperty("Authorization", token); connection.setRequestMethod("GET"); stream = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = stream.readLine()) != null) { builder.append(line); } Stag.Factory factory = new Stag.Factory();
// Path: sample/src/main/java/com/vimeo/sample/model/DateParser.java // public class DateParser extends TypeAdapter<Date> { // // private static final SimpleDateFormat dateFormat = // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ", Locale.ENGLISH); // // @Override // public void write(JsonWriter out, Date value) throws IOException { // out.value(dateFormat.format(value)); // } // // @Override // public Date read(JsonReader in) throws IOException { // try { // return dateFormat.parse(in.nextString()); // } catch (ParseException e) { // throw new IOException("Date parsing failed", e); // } // } // } // // Path: sample/src/main/java/com/vimeo/sample/model/Video.java // @UseStag // public class Video { // // @SerializedName("user") // public User mUser; // // @SerializedName("link") // public String mLink; // // @SerializedName("name") // public String mName; // // @SerializedName("created_time") // public Date mCreatedTime; // // @SerializedName("stats") // public Stats mStats; // // @Override // public String toString() { // return "user: { " + (mUser != null ? mUser.toString() : null) + " }\nlink: " + mLink + "\nname: " + // mName + "\ncreated_time: " + mCreatedTime + "\nstats: { " + // (mStats != null ? mStats.toString() : null) + " }"; // } // } // Path: sample/src/main/java/com/vimeo/sample/network/NetworkRequest.java import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.TypeAdapter; import com.vimeo.sample.model.DateParser; import com.vimeo.sample.model.Video; import com.vimeo.sample.model.VideoList; import com.vimeo.sample.model.VideoList$TypeAdapter; import com.vimeo.sample.stag.generated.Stag; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.Executors; void cancelRequest() { mCallback = null; cancel(true); } @Override protected List<Video> doInBackground(Void... params) { String url = "https://api.vimeo.com/channels/staffpicks/videos"; String token = "bearer b8e31bd89ba1ee093dc6ab0f863db1bd"; ArrayList<Video> videos = new ArrayList<>(); StringBuilder builder = new StringBuilder(); BufferedReader stream = null; try { URL uri = new URL(url); HttpURLConnection connection = (HttpURLConnection) uri.openConnection(); connection.setRequestProperty("Authorization", token); connection.setRequestMethod("GET"); stream = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = stream.readLine()) != null) { builder.append(line); } Stag.Factory factory = new Stag.Factory();
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new DateParser())
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedName2Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedName2Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedName2Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedName2Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(FieldOptionsSerializedName2.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/basic/BasicModel2Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model.basic; /** * Unit tests for {@link BasicModel2}. */ public class BasicModel2Test { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/basic/BasicModel2Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model.basic; /** * Unit tests for {@link BasicModel2}. */ public class BasicModel2Test { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(BasicModel2.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/BaseExternalModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by anthonycr on 2/7/17. */ public class BaseExternalModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/BaseExternalModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by anthonycr on 2/7/17. */ public class BaseExternalModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(BaseExternalModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ObjectExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by anshul.garg on 12/04/17. */ public class ObjectExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ObjectExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by anshul.garg on 12/04/17. */ public class ObjectExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ObjectExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalAbstractClassTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalAbstractClassTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalAbstractClassTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalAbstractClassTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(ExternalAbstractClass.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/AbstractDataListTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link AbstractDataList}. */ public class AbstractDataListTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/AbstractDataListTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link AbstractDataList}. */ public class AbstractDataListTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(AbstractDataList.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelDerivedExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // // Path: integration-test-java/src/main/java/com/vimeo/sample_java_model/BaseExternalModel.java // @UseStag // public class BaseExternalModel { // // @SerializedName("type") // private String mType; // // @SerializedName("base_value") // private int mBaseValue; // // public String getType() { // return mType; // } // // public void setType(String type) { // this.mType = type; // } // // public int getBaseValue() { // return mBaseValue; // } // // public void setBaseValue(int baseValue) { // this.mBaseValue = baseValue; // } // // @Override // public boolean equals(Object o) { // if (this == o) { return true; } // if (o == null || getClass() != o.getClass()) { return false; } // // BaseExternalModel that = (BaseExternalModel) o; // // if (mBaseValue != that.mBaseValue) { return false; } // return mType != null ? mType.equals(that.mType) : that.mType == null; // } // // @Override // public int hashCode() { // int result = mType != null ? mType.hashCode() : 0; // result = 31 * result + mBaseValue; // return result; // } // }
import verification.Utils; import com.vimeo.sample_java_model.BaseExternalModel; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by anthonycr on 2/7/17. */ public class ExternalModelDerivedExampleTest { @Test public void verifyTypeAdapterWasGenerated_ExternalModelDerivedExample() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // // Path: integration-test-java/src/main/java/com/vimeo/sample_java_model/BaseExternalModel.java // @UseStag // public class BaseExternalModel { // // @SerializedName("type") // private String mType; // // @SerializedName("base_value") // private int mBaseValue; // // public String getType() { // return mType; // } // // public void setType(String type) { // this.mType = type; // } // // public int getBaseValue() { // return mBaseValue; // } // // public void setBaseValue(int baseValue) { // this.mBaseValue = baseValue; // } // // @Override // public boolean equals(Object o) { // if (this == o) { return true; } // if (o == null || getClass() != o.getClass()) { return false; } // // BaseExternalModel that = (BaseExternalModel) o; // // if (mBaseValue != that.mBaseValue) { return false; } // return mType != null ? mType.equals(that.mType) : that.mType == null; // } // // @Override // public int hashCode() { // int result = mType != null ? mType.hashCode() : 0; // result = 31 * result + mBaseValue; // return result; // } // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelDerivedExampleTest.java import verification.Utils; import com.vimeo.sample_java_model.BaseExternalModel; import org.junit.Test; package com.vimeo.sample.model; /** * Created by anthonycr on 2/7/17. */ public class ExternalModelDerivedExampleTest { @Test public void verifyTypeAdapterWasGenerated_ExternalModelDerivedExample() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelDerivedExample.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelDerivedExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // // Path: integration-test-java/src/main/java/com/vimeo/sample_java_model/BaseExternalModel.java // @UseStag // public class BaseExternalModel { // // @SerializedName("type") // private String mType; // // @SerializedName("base_value") // private int mBaseValue; // // public String getType() { // return mType; // } // // public void setType(String type) { // this.mType = type; // } // // public int getBaseValue() { // return mBaseValue; // } // // public void setBaseValue(int baseValue) { // this.mBaseValue = baseValue; // } // // @Override // public boolean equals(Object o) { // if (this == o) { return true; } // if (o == null || getClass() != o.getClass()) { return false; } // // BaseExternalModel that = (BaseExternalModel) o; // // if (mBaseValue != that.mBaseValue) { return false; } // return mType != null ? mType.equals(that.mType) : that.mType == null; // } // // @Override // public int hashCode() { // int result = mType != null ? mType.hashCode() : 0; // result = 31 * result + mBaseValue; // return result; // } // }
import verification.Utils; import com.vimeo.sample_java_model.BaseExternalModel; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by anthonycr on 2/7/17. */ public class ExternalModelDerivedExampleTest { @Test public void verifyTypeAdapterWasGenerated_ExternalModelDerivedExample() throws Exception { Utils.verifyTypeAdapterGeneration(ExternalModelDerivedExample.class); } @Test public void verifyNoTypeAdapterWasGenerated_BaseExternalModel() throws Exception { // Since ExternalModelDerivedExample inherits from BaseExternalModel in another // module, we need to make sure that Stag doesn't generate an adapter in both modules.
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // // Path: integration-test-java/src/main/java/com/vimeo/sample_java_model/BaseExternalModel.java // @UseStag // public class BaseExternalModel { // // @SerializedName("type") // private String mType; // // @SerializedName("base_value") // private int mBaseValue; // // public String getType() { // return mType; // } // // public void setType(String type) { // this.mType = type; // } // // public int getBaseValue() { // return mBaseValue; // } // // public void setBaseValue(int baseValue) { // this.mBaseValue = baseValue; // } // // @Override // public boolean equals(Object o) { // if (this == o) { return true; } // if (o == null || getClass() != o.getClass()) { return false; } // // BaseExternalModel that = (BaseExternalModel) o; // // if (mBaseValue != that.mBaseValue) { return false; } // return mType != null ? mType.equals(that.mType) : that.mType == null; // } // // @Override // public int hashCode() { // int result = mType != null ? mType.hashCode() : 0; // result = 31 * result + mBaseValue; // return result; // } // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelDerivedExampleTest.java import verification.Utils; import com.vimeo.sample_java_model.BaseExternalModel; import org.junit.Test; package com.vimeo.sample.model; /** * Created by anthonycr on 2/7/17. */ public class ExternalModelDerivedExampleTest { @Test public void verifyTypeAdapterWasGenerated_ExternalModelDerivedExample() throws Exception { Utils.verifyTypeAdapterGeneration(ExternalModelDerivedExample.class); } @Test public void verifyNoTypeAdapterWasGenerated_BaseExternalModel() throws Exception { // Since ExternalModelDerivedExample inherits from BaseExternalModel in another // module, we need to make sure that Stag doesn't generate an adapter in both modules.
Utils.verifyNoTypeAdapterGeneration(BaseExternalModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/json_adapter/JsonAdapterExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model.json_adapter; /** * Created by anshul.garg on 03/03/17. */ public class JsonAdapterExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/json_adapter/JsonAdapterExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model.json_adapter; /** * Created by anshul.garg on 03/03/17. */ public class JsonAdapterExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(JsonAdapterExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ConcreteDataListTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link ConcreteDataList}. */ public class ConcreteDataListTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ConcreteDataListTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link ConcreteDataList}. */ public class ConcreteDataListTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ConcreteDataList.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModelGenericTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelGenericTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModelGenericTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelGenericTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelGeneric.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/TestExternalExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class TestExternalExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/TestExternalExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class TestExternalExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(TestExternalExample.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExample3Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExample3Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExample3Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExample3Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelExample3.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/SampleInterfaceTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class SampleInterfaceTest { @Test public void typeAdapterWasNotGenerated_SampleInterface() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/SampleInterfaceTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class SampleInterfaceTest { @Test public void typeAdapterWasNotGenerated_SampleInterface() throws Exception {
Utils.verifyNoTypeAdapterGeneration(SampleInterface.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ClassWithArrayTypesTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ClassWithArrayTypesTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ClassWithArrayTypesTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ClassWithArrayTypesTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ClassWithArrayTypes.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedName3Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedName3Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedName3Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedName3Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(FieldOptionsSerializedName3.class);
vimeo/stag-java
stag-library-compiler/src/main/java/com/vimeo/stag/processor/generators/EnumTypeAdapterGenerator.java
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/FileGenUtils.java // public final class FileGenUtils { // // private static final String CODE_BLOCK_ESCAPED_SEPARATOR = "$$"; // private static final String UNESCAPED_SEPARATOR = "$"; // // private FileGenUtils() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Writes a Java file to the file system after // * deleting the previous copy. // * // * @param file the file to write. // * @param filer the Filer to use to do the writing. // * @throws IOException throws an exception if we are unable // * to write the file to the filesystem. // */ // public static void writeToFile(@NotNull JavaFile file, @NotNull Filer filer) throws IOException { // String fileName = // file.packageName.isEmpty() ? file.typeSpec.name : file.packageName + '.' + file.typeSpec.name; // List<Element> originatingElements = file.typeSpec.originatingElements; // JavaFileObject filerSourceFile = filer.createSourceFile(fileName, originatingElements.toArray( // new Element[originatingElements.size()])); // filerSourceFile.delete(); // Writer writer = null; // try { // writer = filerSourceFile.openWriter(); // file.writeTo(writer); // } catch (Exception e) { // try { // filerSourceFile.delete(); // } catch (Exception ignored) { // } // throw e; // } finally { // close(writer); // } // } // // @Nullable // static CharSequence readResource(@NotNull Filer filer, @NotNull String generatedPackageName, // @NotNull String resourceName) throws IOException { // try { // FileObject file = // filer.getResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); // return file.getCharContent(false); // } catch (FileNotFoundException e) { // DebugLog.log("Resource not found: " + resourceName); // return null; // } // } // // static void writeToResource(@NotNull Filer filer, @NotNull String generatedPackageName, // @NotNull String resourceName, @NotNull CharSequence content) // throws IOException { // FileObject file = // filer.createResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); // file.delete(); // Writer writer = null; // try { // writer = file.openWriter(); // writer.append(content); // DebugLog.log("Wrote to resource '" + resourceName + "':\n" + content); // } catch (Exception e) { // try { // file.delete(); // } catch (Exception ignored) { // } // throw e; // } finally { // close(writer); // } // } // // /** // * Safely closes a closeable. // * // * @param closeable object to close. // */ // static void close(@Nullable Closeable closeable) { // if (closeable == null) { // return; // } // try { // closeable.close(); // } catch (IOException e) { // // ignored // } // } // // /** // * Takes a String input and escapes it for use // * in the {@link CodeBlock} class. // * // * @param string the string to escape. // * @return a String safe to use in a {@link CodeBlock} // */ // @NotNull // public static String escapeStringForCodeBlock(@NotNull String string) { // return string.replace(UNESCAPED_SEPARATOR, CODE_BLOCK_ESCAPED_SEPARATOR); // } // // /** // * Takes a String input that was escaped for // * use in the {@link CodeBlock} class and // * unescapes it for normal use. // * // * @param string the String to unescape, // * @return a String safe for normal use. // */ // @NotNull // public static String unescapeEscapedString(@NotNull String string) { // return string.replace(CODE_BLOCK_ESCAPED_SEPARATOR, UNESCAPED_SEPARATOR); // } // }
import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import com.vimeo.stag.processor.generators.model.ClassInfo; import com.vimeo.stag.processor.utils.FileGenUtils; import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror;
.addParameter(JsonReader.class, "reader") .returns(typeName) .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) .addException(IOException.class) .beginControlFlow("if (reader.peek() == com.google.gson.stream.JsonToken.NULL)") .addStatement("reader.nextNull()") .addStatement("return null") .endControlFlow() .addStatement("return NAME_TO_CONSTANT.get(reader.nextString())") .build(); } /** * Generates the TypeSpec for the TypeAdapter * that this enum generates. * * @return a valid TypeSpec that can be written * to a file or added to another class. */ @Override @NotNull public TypeSpec createTypeAdapterSpec(@NotNull StagGenerator stagGenerator) { TypeMirror typeMirror = mInfo.getType(); TypeName typeVariableName = TypeVariableName.get(typeMirror); MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(Gson.class, "gson");
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/FileGenUtils.java // public final class FileGenUtils { // // private static final String CODE_BLOCK_ESCAPED_SEPARATOR = "$$"; // private static final String UNESCAPED_SEPARATOR = "$"; // // private FileGenUtils() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Writes a Java file to the file system after // * deleting the previous copy. // * // * @param file the file to write. // * @param filer the Filer to use to do the writing. // * @throws IOException throws an exception if we are unable // * to write the file to the filesystem. // */ // public static void writeToFile(@NotNull JavaFile file, @NotNull Filer filer) throws IOException { // String fileName = // file.packageName.isEmpty() ? file.typeSpec.name : file.packageName + '.' + file.typeSpec.name; // List<Element> originatingElements = file.typeSpec.originatingElements; // JavaFileObject filerSourceFile = filer.createSourceFile(fileName, originatingElements.toArray( // new Element[originatingElements.size()])); // filerSourceFile.delete(); // Writer writer = null; // try { // writer = filerSourceFile.openWriter(); // file.writeTo(writer); // } catch (Exception e) { // try { // filerSourceFile.delete(); // } catch (Exception ignored) { // } // throw e; // } finally { // close(writer); // } // } // // @Nullable // static CharSequence readResource(@NotNull Filer filer, @NotNull String generatedPackageName, // @NotNull String resourceName) throws IOException { // try { // FileObject file = // filer.getResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); // return file.getCharContent(false); // } catch (FileNotFoundException e) { // DebugLog.log("Resource not found: " + resourceName); // return null; // } // } // // static void writeToResource(@NotNull Filer filer, @NotNull String generatedPackageName, // @NotNull String resourceName, @NotNull CharSequence content) // throws IOException { // FileObject file = // filer.createResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); // file.delete(); // Writer writer = null; // try { // writer = file.openWriter(); // writer.append(content); // DebugLog.log("Wrote to resource '" + resourceName + "':\n" + content); // } catch (Exception e) { // try { // file.delete(); // } catch (Exception ignored) { // } // throw e; // } finally { // close(writer); // } // } // // /** // * Safely closes a closeable. // * // * @param closeable object to close. // */ // static void close(@Nullable Closeable closeable) { // if (closeable == null) { // return; // } // try { // closeable.close(); // } catch (IOException e) { // // ignored // } // } // // /** // * Takes a String input and escapes it for use // * in the {@link CodeBlock} class. // * // * @param string the string to escape. // * @return a String safe to use in a {@link CodeBlock} // */ // @NotNull // public static String escapeStringForCodeBlock(@NotNull String string) { // return string.replace(UNESCAPED_SEPARATOR, CODE_BLOCK_ESCAPED_SEPARATOR); // } // // /** // * Takes a String input that was escaped for // * use in the {@link CodeBlock} class and // * unescapes it for normal use. // * // * @param string the String to unescape, // * @return a String safe for normal use. // */ // @NotNull // public static String unescapeEscapedString(@NotNull String string) { // return string.replace(CODE_BLOCK_ESCAPED_SEPARATOR, UNESCAPED_SEPARATOR); // } // } // Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/generators/EnumTypeAdapterGenerator.java import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import com.vimeo.stag.processor.generators.model.ClassInfo; import com.vimeo.stag.processor.utils.FileGenUtils; import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; .addParameter(JsonReader.class, "reader") .returns(typeName) .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) .addException(IOException.class) .beginControlFlow("if (reader.peek() == com.google.gson.stream.JsonToken.NULL)") .addStatement("reader.nextNull()") .addStatement("return null") .endControlFlow() .addStatement("return NAME_TO_CONSTANT.get(reader.nextString())") .build(); } /** * Generates the TypeSpec for the TypeAdapter * that this enum generates. * * @return a valid TypeSpec that can be written * to a file or added to another class. */ @Override @NotNull public TypeSpec createTypeAdapterSpec(@NotNull StagGenerator stagGenerator) { TypeMirror typeMirror = mInfo.getType(); TypeName typeVariableName = TypeVariableName.get(typeMirror); MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(Gson.class, "gson");
String className = FileGenUtils.unescapeEscapedString(mInfo.getTypeAdapterClassName());
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NestedClassTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class NestedClassTest { @Test public void typeAdapterWasGenerated_NestedClass() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NestedClassTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class NestedClassTest { @Test public void typeAdapterWasGenerated_NestedClass() throws Exception {
Utils.verifyTypeAdapterGeneration(NestedClass.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/ParameterizedDataTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model1; /** * Unit tests for {@link ParameterizedData}. */ public class ParameterizedDataTest { @Test public void verifyTypeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/ParameterizedDataTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model1; /** * Unit tests for {@link ParameterizedData}. */ public class ParameterizedDataTest { @Test public void verifyTypeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(ParameterizedData.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/AccessModifiersTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class AccessModifiersTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/AccessModifiersTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class AccessModifiersTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(AccessModifiers.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelExtensionWithoutAnnotationTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; public class NativeJavaModelExtensionWithoutAnnotationTest { @Test public void typeAdapterWasNotGenerated_NativeJavaModelExtension() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelExtensionWithoutAnnotationTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; public class NativeJavaModelExtensionWithoutAnnotationTest { @Test public void typeAdapterWasNotGenerated_NativeJavaModelExtension() throws Exception {
Utils.verifyNoTypeAdapterGeneration(NativeJavaModelExtensionWithoutAnnotation.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/PrimitiveTypesExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class PrimitiveTypesExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/PrimitiveTypesExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class PrimitiveTypesExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(PrimitiveTypesExample.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/RecursiveClassTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class RecursiveClassTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/RecursiveClassTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class RecursiveClassTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(RecursiveClass.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/DuplicateNameTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model1; /** * Unit tests for {@link DuplicateName}. */ public class DuplicateNameTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/DuplicateNameTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model1; /** * Unit tests for {@link DuplicateName}. */ public class DuplicateNameTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(DuplicateName.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/OuterClassWithInnerModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; public class OuterClassWithInnerModelTest { @Test public void innerTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/OuterClassWithInnerModelTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; public class OuterClassWithInnerModelTest { @Test public void innerTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(OuterClassWithInnerModel.InnerModel.class);
vimeo/stag-java
stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/FileGenUtils.java
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/logging/DebugLog.java // public final class DebugLog { // // private static final String TAG = "Stag"; // @Nullable // private static Logger sLogger; // // private DebugLog() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Initialize the log utils with the logging instance. // * // * @param logger the logging instance, if null is provided, logging will result in a crash. // */ // public static void initialize(@Nullable Logger logger) { // sLogger = logger; // } // // @NotNull // private static Logger safeLogger() { // if (sLogger == null) { // throw new IllegalStateException("initialize must be called first"); // } // return sLogger; // } // // /** // * Log the provided message with the default log tag "Stag" // * // * @param message the message to log. // */ // public static void log(@Nullable CharSequence message) { // safeLogger().log(TAG + ": " + message); // } // // /** // * Log the provided message with an additional log tag. // * // * @param tag the tag to add to the log. // * @param message the message to log. // */ // public static void log(@NotNull CharSequence tag, @Nullable CharSequence message) { // safeLogger().log(TAG + ":" + tag + ": " + message); // } // // }
import java.io.Closeable; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Writer; import java.util.List; import javax.annotation.processing.Filer; import javax.lang.model.element.Element; import javax.tools.FileObject; import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.JavaFile; import com.vimeo.stag.processor.utils.logging.DebugLog; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
public static void writeToFile(@NotNull JavaFile file, @NotNull Filer filer) throws IOException { String fileName = file.packageName.isEmpty() ? file.typeSpec.name : file.packageName + '.' + file.typeSpec.name; List<Element> originatingElements = file.typeSpec.originatingElements; JavaFileObject filerSourceFile = filer.createSourceFile(fileName, originatingElements.toArray( new Element[originatingElements.size()])); filerSourceFile.delete(); Writer writer = null; try { writer = filerSourceFile.openWriter(); file.writeTo(writer); } catch (Exception e) { try { filerSourceFile.delete(); } catch (Exception ignored) { } throw e; } finally { close(writer); } } @Nullable static CharSequence readResource(@NotNull Filer filer, @NotNull String generatedPackageName, @NotNull String resourceName) throws IOException { try { FileObject file = filer.getResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); return file.getCharContent(false); } catch (FileNotFoundException e) {
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/logging/DebugLog.java // public final class DebugLog { // // private static final String TAG = "Stag"; // @Nullable // private static Logger sLogger; // // private DebugLog() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Initialize the log utils with the logging instance. // * // * @param logger the logging instance, if null is provided, logging will result in a crash. // */ // public static void initialize(@Nullable Logger logger) { // sLogger = logger; // } // // @NotNull // private static Logger safeLogger() { // if (sLogger == null) { // throw new IllegalStateException("initialize must be called first"); // } // return sLogger; // } // // /** // * Log the provided message with the default log tag "Stag" // * // * @param message the message to log. // */ // public static void log(@Nullable CharSequence message) { // safeLogger().log(TAG + ": " + message); // } // // /** // * Log the provided message with an additional log tag. // * // * @param tag the tag to add to the log. // * @param message the message to log. // */ // public static void log(@NotNull CharSequence tag, @Nullable CharSequence message) { // safeLogger().log(TAG + ":" + tag + ": " + message); // } // // } // Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/FileGenUtils.java import java.io.Closeable; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Writer; import java.util.List; import javax.annotation.processing.Filer; import javax.lang.model.element.Element; import javax.tools.FileObject; import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.JavaFile; import com.vimeo.stag.processor.utils.logging.DebugLog; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public static void writeToFile(@NotNull JavaFile file, @NotNull Filer filer) throws IOException { String fileName = file.packageName.isEmpty() ? file.typeSpec.name : file.packageName + '.' + file.typeSpec.name; List<Element> originatingElements = file.typeSpec.originatingElements; JavaFileObject filerSourceFile = filer.createSourceFile(fileName, originatingElements.toArray( new Element[originatingElements.size()])); filerSourceFile.delete(); Writer writer = null; try { writer = filerSourceFile.openWriter(); file.writeTo(writer); } catch (Exception e) { try { filerSourceFile.delete(); } catch (Exception ignored) { } throw e; } finally { close(writer); } } @Nullable static CharSequence readResource(@NotNull Filer filer, @NotNull String generatedPackageName, @NotNull String resourceName) throws IOException { try { FileObject file = filer.getResource(StandardLocation.CLASS_OUTPUT, generatedPackageName, resourceName); return file.getCharContent(false); } catch (FileNotFoundException e) {
DebugLog.log("Resource not found: " + resourceName);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/SubClassWithSameVariableNameTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class SubClassWithSameVariableNameTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/SubClassWithSameVariableNameTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class SubClassWithSameVariableNameTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(SubClassWithSameVariableName.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/DynamicallyTypedWildcardTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link DynamicallyTypedWildcard}. */ public class DynamicallyTypedWildcardTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/DynamicallyTypedWildcardTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link DynamicallyTypedWildcard}. */ public class DynamicallyTypedWildcardTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(DynamicallyTypedWildcard.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/DataTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model1; /** * Created by restainoa on 2/2/17. */ public class DataTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model1/DataTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model1; /** * Created by restainoa on 2/2/17. */ public class DataTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(Data.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/BooleanFieldsTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Unit tests for {@link BooleanFields}. * <p> * Created by anthonycr on 9/2/17. */ public class BooleanFieldsTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/BooleanFieldsTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Unit tests for {@link BooleanFields}. * <p> * Created by anthonycr on 9/2/17. */ public class BooleanFieldsTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(BooleanFields.class);
vimeo/stag-java
integration-test-android/src/test/java/com/vimeo/integration_test_android/ClassWithMapTypesTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.integration_test_android; /** * Created by restainoa on 2/2/17. */ public class ClassWithMapTypesTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-android/src/test/java/com/vimeo/integration_test_android/ClassWithMapTypesTest.java import org.junit.Test; import verification.Utils; package com.vimeo.integration_test_android; /** * Created by restainoa on 2/2/17. */ public class ClassWithMapTypesTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ClassWithMapTypes.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelExtensionTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; public class NativeJavaModelExtensionTest { @Test public void typeAdapterWasGenerated_NativeJavaModelExtension() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeJavaModelExtensionTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; public class NativeJavaModelExtensionTest { @Test public void typeAdapterWasGenerated_NativeJavaModelExtension() throws Exception {
Utils.verifyTypeAdapterGeneration(NativeJavaModelExtension.class);
vimeo/stag-java
integration-test-android/src/test/java/com/vimeo/integration_test_android/TestModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.integration_test_android; /** * Unit tests for {@link TestModel}. */ public class TestModelTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-android/src/test/java/com/vimeo/integration_test_android/TestModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.integration_test_android; /** * Unit tests for {@link TestModel}. */ public class TestModelTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(TestModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedNameTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedNameTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionsSerializedNameTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionsSerializedNameTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(FieldOptionsSerializedName.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeArrayTypesTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Unit tests for {@link NativeArrayTypes}. */ public class NativeArrayTypesTest { @Test public void verifyTypeAdapterWasGenerated() {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/NativeArrayTypesTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Unit tests for {@link NativeArrayTypes}. */ public class NativeArrayTypesTest { @Test public void verifyTypeAdapterWasGenerated() {
Utils.verifyTypeAdapterGeneration(NativeArrayTypes.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ClassWithNestedInterfaceTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ClassWithNestedInterfaceTest { @Test public void typeAdapterWasNotGenerated_AvailabilityIntentDef() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ClassWithNestedInterfaceTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ClassWithNestedInterfaceTest { @Test public void typeAdapterWasNotGenerated_AvailabilityIntentDef() throws Exception {
Utils.verifyNoTypeAdapterGeneration(ClassWithNestedInterface.AvailabilityIntentDef.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/AnnotationExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class AnnotationExampleTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/AnnotationExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class AnnotationExampleTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(AnnotationExample.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NestedEnumTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; public class NestedEnumTest { @Test public void typeAdapterWasGenerated_NestedEnum() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/NestedEnumTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; public class NestedEnumTest { @Test public void typeAdapterWasGenerated_NestedEnum() throws Exception {
Utils.verifyTypeAdapterGeneration(NestedEnum.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelExample.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/SuperAbstractDataListTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link SuperAbstractDataList}. */ public class SuperAbstractDataListTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/SuperAbstractDataListTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link SuperAbstractDataList}. */ public class SuperAbstractDataListTest { @Test public void typeAdapterWasNotGenerated() throws Exception {
Utils.verifyNoTypeAdapterGeneration(SuperAbstractDataList.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/RawGenericFieldTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Integration tests for {@link RawGenericField}. */ public class RawGenericFieldTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/RawGenericFieldTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Integration tests for {@link RawGenericField}. */ public class RawGenericFieldTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(RawGenericField.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/WrapperTypeAdapterModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vimeo.sample_java_model.WrapperTypeAdapterModel.InnerType; import com.vimeo.sample_java_model.stag.generated.Stag; import org.junit.Test; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import verification.Utils; import static org.junit.Assert.assertEquals;
package com.vimeo.sample_java_model; /** * Unit tests for {@link WrapperTypeAdapterModel}. * <p> * Created by restainoa on 12/18/17. */ public class WrapperTypeAdapterModelTest { @Test public void verifyTypeAdapterWasGenerated_WrapperTypeAdapterModel() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/WrapperTypeAdapterModelTest.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vimeo.sample_java_model.WrapperTypeAdapterModel.InnerType; import com.vimeo.sample_java_model.stag.generated.Stag; import org.junit.Test; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import verification.Utils; import static org.junit.Assert.assertEquals; package com.vimeo.sample_java_model; /** * Unit tests for {@link WrapperTypeAdapterModel}. * <p> * Created by restainoa on 12/18/17. */ public class WrapperTypeAdapterModelTest { @Test public void verifyTypeAdapterWasGenerated_WrapperTypeAdapterModel() throws Exception {
Utils.verifyTypeAdapterGeneration(WrapperTypeAdapterModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionAllExampleTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionAllExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/FieldOptionAllExampleTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class FieldOptionAllExampleTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(FieldOptionAllExample.class);
vimeo/stag-java
stag-library/src/test/java/com/vimeo/stag/KnownTypeAdaptersTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.TypeAdapter; import com.google.gson.internal.bind.TypeAdapters; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.junit.Test; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.HashMap; import verification.Utils; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals;
StringWriter stringWriter1 = new StringWriter(); KnownTypeAdapters.PrimitiveCharArrayAdapter.write(new JsonWriter(stringWriter1), value1); String jsonString1 = stringWriter1.toString(); // call the TypeAdapter#read method char[] readValue1 = KnownTypeAdapters.PrimitiveCharArrayAdapter.read(new JsonReader(new StringReader(jsonString1))); assertArrayEquals(value1, readValue1); } @Test public void primitiveArrayCharacterTypeAdapterHandlesNullsCorrectly() throws Exception { final char[] input = null; StringWriter stringWriter = new StringWriter(); KnownTypeAdapters.PrimitiveCharArrayAdapter.write(new JsonWriter(stringWriter), input); String jsonString = stringWriter.toString(); // call the TypeAdapter#read method char[] readValue = KnownTypeAdapters.PrimitiveCharArrayAdapter.read(new JsonReader(new StringReader(jsonString))); assertEquals(input, readValue); } /** * Test for {@link KnownTypeAdapters.ListTypeAdapter} */ @Test public void testForListTypeAdapter() throws Exception { // for string arrays
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: stag-library/src/test/java/com/vimeo/stag/KnownTypeAdaptersTest.java import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.TypeAdapter; import com.google.gson.internal.bind.TypeAdapters; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.junit.Test; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.HashMap; import verification.Utils; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; StringWriter stringWriter1 = new StringWriter(); KnownTypeAdapters.PrimitiveCharArrayAdapter.write(new JsonWriter(stringWriter1), value1); String jsonString1 = stringWriter1.toString(); // call the TypeAdapter#read method char[] readValue1 = KnownTypeAdapters.PrimitiveCharArrayAdapter.read(new JsonReader(new StringReader(jsonString1))); assertArrayEquals(value1, readValue1); } @Test public void primitiveArrayCharacterTypeAdapterHandlesNullsCorrectly() throws Exception { final char[] input = null; StringWriter stringWriter = new StringWriter(); KnownTypeAdapters.PrimitiveCharArrayAdapter.write(new JsonWriter(stringWriter), input); String jsonString = stringWriter.toString(); // call the TypeAdapter#read method char[] readValue = KnownTypeAdapters.PrimitiveCharArrayAdapter.read(new JsonReader(new StringReader(jsonString))); assertEquals(input, readValue); } /** * Test for {@link KnownTypeAdapters.ListTypeAdapter} */ @Test public void testForListTypeAdapter() throws Exception { // for string arrays
ArrayList<String> dummyList = Utils.createStringDummyList();
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/SwappableParserExampleModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.io.IOException; import verification.Utils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vimeo.sample_java_model.SwappableParserExampleModel.TestObject; import com.vimeo.sample_java_model.stag.generated.Stag;
/* * The MIT License (MIT) * <p/> * Copyright (c) 2017 Vimeo * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.vimeo.sample_java_model; /** * Unit tests for {@link SwappableParserExampleModel}. */ public class SwappableParserExampleModelTest { @Test public void verifyTypeAdapterWasGenerated_SwappableParserExampleModel() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/SwappableParserExampleModelTest.java import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.io.IOException; import verification.Utils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.vimeo.sample_java_model.SwappableParserExampleModel.TestObject; import com.vimeo.sample_java_model.stag.generated.Stag; /* * The MIT License (MIT) * <p/> * Copyright (c) 2017 Vimeo * <p/> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * <p/> * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * <p/> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.vimeo.sample_java_model; /** * Unit tests for {@link SwappableParserExampleModel}. */ public class SwappableParserExampleModelTest { @Test public void verifyTypeAdapterWasGenerated_SwappableParserExampleModel() throws Exception {
Utils.verifyTypeAdapterGeneration(SwappableParserExampleModel.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/DuplicateNameTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Unit tests for {@link DuplicateName}. */ public class DuplicateNameTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/DuplicateNameTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Unit tests for {@link DuplicateName}. */ public class DuplicateNameTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(DuplicateName.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModel2Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModel2Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ExternalModel2Test.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class ExternalModel2Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModel2.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/ModelWithNestedInterfaceTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/3/17. */ public class ModelWithNestedInterfaceTest { @Test public void typeAdapterWasGenerated_ModelWithNestedInterface() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/ModelWithNestedInterfaceTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/3/17. */ public class ModelWithNestedInterfaceTest { @Test public void typeAdapterWasGenerated_ModelWithNestedInterface() throws Exception {
Utils.verifyTypeAdapterGeneration(ModelWithNestedInterface.class);
vimeo/stag-java
integration-test-android/src/test/java/com/vimeo/integration_test_android/ComplexGenericClassExtendedTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.integration_test_android; public class ComplexGenericClassExtendedTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-android/src/test/java/com/vimeo/integration_test_android/ComplexGenericClassExtendedTest.java import org.junit.Test; import verification.Utils; package com.vimeo.integration_test_android; public class ComplexGenericClassExtendedTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ComplexGenericClassExtended.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ConcreteClassTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ConcreteClassTest { @Test public void typeAdapterWasGenerated_ConcreteClass() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ConcreteClassTest.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ConcreteClassTest { @Test public void typeAdapterWasGenerated_ConcreteClass() throws Exception {
Utils.verifyTypeAdapterGeneration(ConcreteClass.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/PrivateMembersTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Tests for {@link PrivateMembers}. * <p> * Created by anthonycr on 5/16/17. */ public class PrivateMembersTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/PrivateMembersTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Tests for {@link PrivateMembers}. * <p> * Created by anthonycr on 5/16/17. */ public class PrivateMembersTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(PrivateMembers.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/basic/BasicModel1Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model.basic; /** * Unit tests for {@link BasicModel1}. */ public class BasicModel1Test { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/basic/BasicModel1Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model.basic; /** * Unit tests for {@link BasicModel1}. */ public class BasicModel1Test { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(BasicModel1.class);
vimeo/stag-java
integration-test-android/src/test/java/com/vimeo/integration_test_android/UnserializablePlatformTypeTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.integration_test_android; /** * Unit tests for {@link UnserializablePlatformType}. */ public class UnserializablePlatformTypeTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-android/src/test/java/com/vimeo/integration_test_android/UnserializablePlatformTypeTest.java import org.junit.Test; import verification.Utils; package com.vimeo.integration_test_android; /** * Unit tests for {@link UnserializablePlatformType}. */ public class UnserializablePlatformTypeTest { @Test public void verifyTypeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(UnserializablePlatformType.class);
vimeo/stag-java
stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/TypeUtils.java
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/logging/DebugLog.java // public final class DebugLog { // // private static final String TAG = "Stag"; // @Nullable // private static Logger sLogger; // // private DebugLog() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Initialize the log utils with the logging instance. // * // * @param logger the logging instance, if null is provided, logging will result in a crash. // */ // public static void initialize(@Nullable Logger logger) { // sLogger = logger; // } // // @NotNull // private static Logger safeLogger() { // if (sLogger == null) { // throw new IllegalStateException("initialize must be called first"); // } // return sLogger; // } // // /** // * Log the provided message with the default log tag "Stag" // * // * @param message the message to log. // */ // public static void log(@Nullable CharSequence message) { // safeLogger().log(TAG + ": " + message); // } // // /** // * Log the provided message with an additional log tag. // * // * @param tag the tag to add to the log. // * @param message the message to log. // */ // public static void log(@NotNull CharSequence tag, @Nullable CharSequence message) { // safeLogger().log(TAG + ":" + tag + ": " + message); // } // // }
import com.google.gson.JsonDeserializer; import com.google.gson.JsonSerializer; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.vimeo.stag.processor.generators.model.accessor.FieldAccessor; import com.vimeo.stag.processor.utils.logging.DebugLog; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.WildcardType; import javax.lang.model.util.Types;
* VideoFactory extends {@literal Factory<Video>}{ * * // other variables in here * * } * </code></pre> * In this example, VideoFactory has a public member variable T that is of type Video. * Since the Factory class has the UseStag annotation, we cannot just generate * parsing code for the Factory class, since it is generic and we need concrete types. * Instead when we generate the adapter for VideoFactory, we crawl the inheritance * hierarchy gathering the member variables. When we get to VideoFactory, we see it * has one member variable, T. We then look at the inherited type, Factory{@literal <Video>}, * and compare it to the original type, Factory{@literal <T>}, and then infer the type * of T to be Video. * * @param concreteInherited the type inherited for the class you are using, in the example, * this would be Factory{@literal <Video>} * @param genericInherited the raw type inherited for the class you are using, in the example, * this would be Factory{@literal <T>} * @param members the member variable map of the field (Element) to their concrete * type (TypeMirror). This should be retrieved by calling getConcreteMembers * on the inherited class. * @return returns a LinkedHashMap of the member variables mapped to their concrete types for the concrete * inherited class. (to maintain the ordering) */ @NotNull public static LinkedHashMap<FieldAccessor, TypeMirror> getConcreteMembers(@NotNull TypeMirror concreteInherited, @NotNull TypeElement genericInherited, @NotNull Map<FieldAccessor, TypeMirror> members) {
// Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/logging/DebugLog.java // public final class DebugLog { // // private static final String TAG = "Stag"; // @Nullable // private static Logger sLogger; // // private DebugLog() { // throw new UnsupportedOperationException("This class is not instantiable"); // } // // /** // * Initialize the log utils with the logging instance. // * // * @param logger the logging instance, if null is provided, logging will result in a crash. // */ // public static void initialize(@Nullable Logger logger) { // sLogger = logger; // } // // @NotNull // private static Logger safeLogger() { // if (sLogger == null) { // throw new IllegalStateException("initialize must be called first"); // } // return sLogger; // } // // /** // * Log the provided message with the default log tag "Stag" // * // * @param message the message to log. // */ // public static void log(@Nullable CharSequence message) { // safeLogger().log(TAG + ": " + message); // } // // /** // * Log the provided message with an additional log tag. // * // * @param tag the tag to add to the log. // * @param message the message to log. // */ // public static void log(@NotNull CharSequence tag, @Nullable CharSequence message) { // safeLogger().log(TAG + ":" + tag + ": " + message); // } // // } // Path: stag-library-compiler/src/main/java/com/vimeo/stag/processor/utils/TypeUtils.java import com.google.gson.JsonDeserializer; import com.google.gson.JsonSerializer; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.vimeo.stag.processor.generators.model.accessor.FieldAccessor; import com.vimeo.stag.processor.utils.logging.DebugLog; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.WildcardType; import javax.lang.model.util.Types; * VideoFactory extends {@literal Factory<Video>}{ * * // other variables in here * * } * </code></pre> * In this example, VideoFactory has a public member variable T that is of type Video. * Since the Factory class has the UseStag annotation, we cannot just generate * parsing code for the Factory class, since it is generic and we need concrete types. * Instead when we generate the adapter for VideoFactory, we crawl the inheritance * hierarchy gathering the member variables. When we get to VideoFactory, we see it * has one member variable, T. We then look at the inherited type, Factory{@literal <Video>}, * and compare it to the original type, Factory{@literal <T>}, and then infer the type * of T to be Video. * * @param concreteInherited the type inherited for the class you are using, in the example, * this would be Factory{@literal <Video>} * @param genericInherited the raw type inherited for the class you are using, in the example, * this would be Factory{@literal <T>} * @param members the member variable map of the field (Element) to their concrete * type (TypeMirror). This should be retrieved by calling getConcreteMembers * on the inherited class. * @return returns a LinkedHashMap of the member variables mapped to their concrete types for the concrete * inherited class. (to maintain the ordering) */ @NotNull public static LinkedHashMap<FieldAccessor, TypeMirror> getConcreteMembers(@NotNull TypeMirror concreteInherited, @NotNull TypeElement genericInherited, @NotNull Map<FieldAccessor, TypeMirror> members) {
DebugLog.log(TAG, "Inherited concrete type: " + concreteInherited.toString());
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/EnumWithFieldsModelTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by anthonycr on 4/9/17. */ public class EnumWithFieldsModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/EnumWithFieldsModelTest.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by anthonycr on 4/9/17. */ public class EnumWithFieldsModelTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(EnumWithFieldsModel.class);
vimeo/stag-java
integration-test-android/src/test/java/com/vimeo/integration_test_android/ComplexGenericClassTest.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.integration_test_android; /** * Created by restainoa on 2/2/17. */ public class ComplexGenericClassTest { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-android/src/test/java/com/vimeo/integration_test_android/ComplexGenericClassTest.java import org.junit.Test; import verification.Utils; package com.vimeo.integration_test_android; /** * Created by restainoa on 2/2/17. */ public class ComplexGenericClassTest { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ComplexGenericClass.class);
vimeo/stag-java
integration-test-java/src/test/java/com/vimeo/sample_java_model/AlternateNameModel1Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import org.junit.Test; import verification.Utils;
package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class AlternateNameModel1Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java/src/test/java/com/vimeo/sample_java_model/AlternateNameModel1Test.java import org.junit.Test; import verification.Utils; package com.vimeo.sample_java_model; /** * Created by restainoa on 2/2/17. */ public class AlternateNameModel1Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(AlternateNameModel1.class);
vimeo/stag-java
integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExample1Test.java
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // }
import verification.Utils; import org.junit.Test;
package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExample1Test { @Test public void typeAdapterWasGenerated() throws Exception {
// Path: integration-test-java/src/test/java/verification/Utils.java // public final class Utils { // // private Utils() { // } // // private static <T> TypeAdapter<T> getTypeAdapter(@NotNull Class<T> clazz) { // Gson gson = new Gson(); // Stag.Factory factory = new Stag.Factory(); // TypeToken<T> innerModelType = TypeToken.get(clazz); // return factory.create(gson, innerModelType); // } // // /** // * Verifies that a TypeAdapter was generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNotNull("Type adapter should have been generated by Stag", typeAdapter); // } // // /** // * Verifies that a TypeAdapter was NOT generated for the specified class. // * // * @param clazz the class to check. // * @param <T> the type of the class, used internally. // */ // public static <T> void verifyNoTypeAdapterGeneration(@NotNull Class<T> clazz) { // TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // assertNull("Type adapter should not have been generated by Stag", typeAdapter); // } // // /** // * Verifies that the type adapter for a class is correct. It does this by manufacturing an // * instance of the class, writing it to JSON, and then reading that object back out of JSON // * and comparing the two instances. // * // * @param clazz the {@link Class} to use to get the {@link TypeAdapter}. // */ // public static <T> void verifyTypeAdapterCorrectness(@NotNull Class<T> clazz) { // final PodamFactory factory = new PodamFactoryImpl(); // factory.setClassStrategy(new HungarianNotationClassInfoStrategy()); // // final T object = factory.manufacturePojo(clazz); // final TypeAdapter<T> typeAdapter = getTypeAdapter(clazz); // // T newObject = null; // if (typeAdapter != null) { // final String json = typeAdapter.toJson(object); // try { // newObject = typeAdapter.fromJson(json); // } catch (IOException ignored) {} // } // // assertEquals(object, newObject); // } // // } // Path: integration-test-java-cross-module/src/test/java/com/vimeo/sample/model/ExternalModelExample1Test.java import verification.Utils; import org.junit.Test; package com.vimeo.sample.model; /** * Created by restainoa on 2/2/17. */ public class ExternalModelExample1Test { @Test public void typeAdapterWasGenerated() throws Exception {
Utils.verifyTypeAdapterGeneration(ExternalModelExample1.class);