Skip to main content
summaryrefslogtreecommitdiffstats
blob: 998d5662b9ac24feee4b6471f368ee28aafca879 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.core.message.test.data;

import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.message.TransactionCacheUpdateResponse;
import org.eclipse.osee.framework.core.message.test.mocks.DataAsserts;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
import org.eclipse.osee.framework.core.model.mocks.MockDataFactory;
import org.eclipse.osee.framework.jdk.core.util.Compare;
import org.junit.Test;

/**
 * Test Case for {@link TransactionCacheUpdateResponse}
 * 
 * @author Roberto E. Escobar
 */
public class TransactionCacheUpdateResponseTest {

   @Test
   public void testGetRows() {
      List<TransactionRecord> expected = new ArrayList<TransactionRecord>();
      for (int j = 1; j <= 2; j++) {
         expected.add(MockDataFactory.createTransaction(j, j * 3));
      }

      TransactionCacheUpdateResponse response = new TransactionCacheUpdateResponse(expected);
      List<TransactionRecord> actual = response.getTxRows();
      Assert.assertFalse(Compare.isDifferent(expected, actual));
   }

   @Test
   public void testFromCache() throws OseeCoreException {

      List<TransactionRecord> data = new ArrayList<TransactionRecord>();
      for (int j = 1; j <= 2; j++) {
         data.add(MockDataFactory.createTransaction(j, j * 3));
      }

      TransactionRecordFactory factory = new TransactionRecordFactory();
      TransactionCacheUpdateResponse response = TransactionCacheUpdateResponse.fromCache(factory, data);
      List<TransactionRecord> actual = response.getTxRows();
      Assert.assertEquals(data.size(), actual.size());
      for (int index = 0; index < data.size(); index++) {
         DataAsserts.assertEquals(data.get(index), actual.get(index));
      }
   }
}

Back to the top