Package com.netflix.zeno.testpojos

Examples of com.netflix.zeno.testpojos.TypeA


        Assert.assertTrue(getAll("TypeB").contains(deserializedC.getTypeBs().get(1)));
    }

    private Map<String, TypeA> typeAMap() {
        final Map<String, TypeA> map = new HashMap<String, TypeA>();
        map.put("ED", new TypeA(12, 34));
        map.put("BR", new TypeA(56, 78));
        return map;
    }
View Full Code Here


    @Test
    public void test() {
        List<TypeA> list1 = new ArrayList<TypeA>();
        List<TypeA> list2 = new ArrayList<TypeA>();

        list1.add(new TypeA(1, 2));
        list2.add(new TypeA(1, 2));

        list1.add(new TypeA(2, 3));
        list2.add(new TypeA(2, 4));

        list1.add(new TypeA(3, 4));
        list2.add(new TypeA(4, 6));

        list1.add(new TypeA(5, 7));
        list2.add(new TypeA(5, 8));

        list1.add(new TypeA(6, 9));
        list2.add(new TypeA(6, 10));

        list1.add(new TypeA(7, 11));
        list2.add(new TypeA(8, 12));

        TypeDiffInstruction<TypeA> diffInstruction = new TypeDiffInstruction<TypeA>() {
            public String getSerializerName() {
                return "TypeA";
            }

            @Override
            public Object getKey(TypeA object) {
                return Integer.valueOf(object.getVal1());
            }
        };

        TypeDiffOperation<TypeA> diffOperation = new TypeDiffOperation<TypeA>(diffInstruction);

        TypeDiff<TypeA> typeDiff = diffOperation.performDiff(framework, list1, list2, 2);

        Assert.assertEquals(2, typeDiff.getExtraInFrom().size());
        Assert.assertTrue(typeDiff.getExtraInFrom().contains(new TypeA(3, 4)));
        Assert.assertTrue(typeDiff.getExtraInFrom().contains(new TypeA(7, 11)));

        Assert.assertEquals(2, typeDiff.getExtraInTo().size());
        Assert.assertTrue(typeDiff.getExtraInTo().contains(new TypeA(4, 6)));
        Assert.assertTrue(typeDiff.getExtraInTo().contains(new TypeA(8, 12)));

        Assert.assertEquals(3, typeDiff.getDiffObjects().size());
        Assert.assertEquals(2, typeDiff.getDiffObjects().get(0).getScore());
        Assert.assertEquals(2, typeDiff.getDiffObjects().get(1).getScore());
        Assert.assertEquals(2, typeDiff.getDiffObjects().get(2).getScore());

        long fromHashTotal = 0;
        long toHashTotal = 0;
        for (ObjectDiffScore<TypeA> diffScore : typeDiff.getDiffObjects()) {
            TypeA type = diffScore.getFrom();
            Assert.assertTrue(type.equals(new TypeA(2, 3)) || type.equals(new TypeA(5, 7)) || type.equals(new TypeA(6, 9)));

            TypeA toType = diffScore.getTo();
            Assert.assertTrue(toType.equals(new TypeA(2, 4)) || toType.equals(new TypeA(5, 8)) || toType.equals(new TypeA(6, 10)));

            fromHashTotal += type.hashCode();
            toHashTotal += toType.hashCode();
        }
        Assert.assertEquals(650, fromHashTotal);
        Assert.assertEquals(689, toHashTotal);

        Assert.assertEquals(2, typeDiff.getSortedFieldDifferencesDescending().size());
View Full Code Here

    private void assertDiffObjectHistoricalState(List<DiffObjectHistoricalTransition<TypeA>> list, Integer... expectedHistory) {
        for(int i=0;i<list.size();i++) {
            Integer expectedFrom = expectedHistory[i+1];
            Integer expectedTo = expectedHistory[i];

            TypeA beforeA = list.get(i).getBefore();
            TypeA afterA = list.get(i).getAfter();

            Integer actualFrom = beforeA == null ? null : beforeA.getVal2();
            Integer actualTo = afterA == null ? null : afterA.getVal2();

            Assert.assertEquals(expectedFrom, actualFrom);
            Assert.assertEquals(expectedTo, actualTo);
        }
    }
View Full Code Here

            Assert.assertEquals(expectedTo, actualTo);
        }
    }

    private void addHistoricalState(Integer one, Integer two, Integer three, Integer four) throws IOException {
        if(one != null)   stateEngine.add("TypeA", new TypeA(1, one.intValue()));
        if(two != null)   stateEngine.add("TypeA", new TypeA(2, two.intValue()));
        if(three != null) stateEngine.add("TypeA", new TypeA(3, three.intValue()));
        if(four != nullstateEngine.add("TypeA", new TypeA(4, four.intValue()));

        stateEngine.setLatestVersion(String.valueOf(++versionCounter));

        roundTripObjects(stateEngine);
        diffHistory.addState();
View Full Code Here

   
    @Before
    public void setUp() throws IOException {
        stateEngine = new FastBlobStateEngine(serializerFactory());
       
        stateEngine.add("TypeA", new TypeA(1, 1));
        stateEngine.add("TypeA", new TypeA(2, 2));
        stateEngine.add("TypeA", new TypeA(3, 1));
        stateEngine.add("TypeA", new TypeA(4, 1));
        stateEngine.add("TypeA", new TypeA(5, 3));
       
        roundTripObjects(stateEngine);
    }
View Full Code Here

    @Test
    public void producesJson() {
        JsonSerializationFramework jsonFramework = new JsonSerializationFramework(typeASerializerFactory);

        String json = jsonFramework.serializeAsJson("TypeA", new TypeA(1, 2));

        Assert.assertEquals(expectedTypeAJson, json);
    }
View Full Code Here

    @Test
    public void consumesJson() throws IOException {
        JsonSerializationFramework jsonFramework = new JsonSerializationFramework(typeASerializerFactory);

        TypeA deserializedTypeA = jsonFramework.deserializeJson("TypeA", expectedTypeAJson);

        Assert.assertEquals(1, deserializedTypeA.getVal1());
        Assert.assertEquals(2, deserializedTypeA.getVal2());
    }
View Full Code Here

    }

    @Test
    public void roundTripJsonMap() throws IOException {
        Map<Integer, TypeA> map = new HashMap<Integer, TypeA>();
        map.put(1, new TypeA(0, 1));
        map.put(2, new TypeA(2, 3));

        JsonSerializationFramework jsonFramework = new JsonSerializationFramework(new SerializerFactory() {
            public NFTypeSerializer<?>[] createSerializers() {
                return new NFTypeSerializer<?>[] { new TypeASerializer(), new IntegerSerializer() };
            }
        });

        String json = jsonFramework.serializeJsonMap(IntegerSerializer.NAME, "TypeA", map, true);

        Map<Integer, TypeA> deserializedMap = jsonFramework.deserializeJsonMap(IntegerSerializer.NAME, "TypeA", json);

        Assert.assertEquals(2, deserializedMap.size());
        Assert.assertEquals(new TypeA(0, 1), deserializedMap.get(1));
        Assert.assertEquals(new TypeA(2, 3), deserializedMap.get(2));
    }
View Full Code Here

    @Test
    public void roundTripJsonWithTwoHierarchicalLevels() throws IOException {
        JsonSerializationFramework jsonFramework = new JsonSerializationFramework(typeGSerializerFactory);

        String json = jsonFramework.serializeAsJson("TypeG", new TypeG(new TypeD(1, new TypeA(2, 3))));

        try {
            jsonFramework.deserializeJson("TypeG", json);
        } catch(Exception e) {
            Assert.fail("Exception was thrown");
View Full Code Here

    private TypeC createTestTypeC() {
        Map<String, TypeA> typeAMap = new HashMap<String, TypeA>();
        List<TypeB> typeBs = new ArrayList<TypeB>();

        typeAMap.put("a12", new TypeA(1, 2));
        typeAMap.put("a34", new TypeA(3, 4));

        typeBs.add(new TypeB(5, "five"));
        typeBs.add(new TypeB(6, "six"));

        return new TypeC(typeAMap, typeBs);
View Full Code Here

TOP

Related Classes of com.netflix.zeno.testpojos.TypeA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.