use of java.io.Serializable in project pinot by linkedin.
the class SelectionOperatorServiceTest method testCompatibleRowsRenderSelectionResultsWithoutOrdering.
@Test
public void testCompatibleRowsRenderSelectionResultsWithoutOrdering() {
List<Serializable[]> rows = new ArrayList<>(2);
rows.add(_row1.clone());
rows.add(_compatibleRow1.clone());
SelectionResults selectionResults = SelectionOperatorUtils.renderSelectionResultsWithoutOrdering(rows, _upgradedDataSchema, Arrays.asList(_columnNames));
List<Serializable[]> formattedRows = selectionResults.getRows();
Serializable[] expectedFormattedRow1 = { "0", "1.0", "2.0", "3.0", "4", new String[] { "5" }, new String[] { "6.0" }, new String[] { "7.0" }, new String[] { "8.0" }, new String[] { "9" } };
Serializable[] expectedFormattedRow2 = { "1", "2.0", "3.0", "4.0", "5", new String[] { "6" }, new String[] { "7.0" }, new String[] { "8.0" }, new String[] { "9.0" }, new String[] { "10" } };
Assert.assertEquals(formattedRows.get(0), expectedFormattedRow1);
Assert.assertEquals(formattedRows.get(1), expectedFormattedRow2);
}
use of java.io.Serializable in project pinot by linkedin.
the class SelectionOperatorServiceTest method testCompatibleRowsRenderSelectionResultsWithOrdering.
@Test
public void testCompatibleRowsRenderSelectionResultsWithOrdering() {
SelectionOperatorService selectionOperatorService = new SelectionOperatorService(_selectionOrderBy, _upgradedDataSchema);
PriorityQueue<Serializable[]> rows = selectionOperatorService.getRows();
rows.offer(_row1.clone());
rows.offer(_compatibleRow1.clone());
rows.offer(_compatibleRow2.clone());
SelectionResults selectionResults = selectionOperatorService.renderSelectionResultsWithOrdering();
List<Serializable[]> formattedRows = selectionResults.getRows();
Serializable[] expectedFormattedRow1 = { "1", "2.0", "3.0", "4.0", "5", new String[] { "6" }, new String[] { "7.0" }, new String[] { "8.0" }, new String[] { "9.0" }, new String[] { "10" } };
Serializable[] expectedFormattedRow2 = { "0", "1.0", "2.0", "3.0", "4", new String[] { "5" }, new String[] { "6.0" }, new String[] { "7.0" }, new String[] { "8.0" }, new String[] { "9" } };
Assert.assertEquals(formattedRows.get(0), expectedFormattedRow1);
Assert.assertEquals(formattedRows.get(1), expectedFormattedRow2);
}
use of java.io.Serializable in project silk by jbee.
the class TestMockingBinds method wildcardBindsDoFallBackToMostGeneralIfRequired.
@Test
public void wildcardBindsDoFallBackToMostGeneralIfRequired() {
Injector injector = Bootstrap.injector(TestMockingBindsModule.class);
Serializable mock = injector.resolve(dependency(Serializable.class));
assertTrue(isProxyClass(mock.getClass()));
assertEquals(Object.class.getCanonicalName(), mock.toString());
}
use of java.io.Serializable in project hibernate-orm by hibernate.
the class NativeSQLQueriesTest method testMappedAliasStrategy.
@Test
@SuppressWarnings({ "deprecation", "UnusedDeclaration" })
public void testMappedAliasStrategy() {
Session s = openSession();
Transaction t = s.beginTransaction();
Organization ifa = new Organization("IFA");
Organization jboss = new Organization("JBoss");
Person gavin = new Person("Gavin");
Employment emp = new Employment(gavin, jboss, "AU");
Serializable orgId = s.save(jboss);
Serializable orgId2 = s.save(ifa);
s.save(gavin);
s.save(emp);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
Query namedQuery = s.getNamedQuery("AllEmploymentAsMapped");
List list = namedQuery.list();
assertEquals(1, list.size());
Employment emp2 = (Employment) list.get(0);
assertEquals(emp2.getEmploymentId(), emp.getEmploymentId());
assertEquals(emp2.getStartDate().getDate(), emp.getStartDate().getDate());
assertEquals(emp2.getEndDate(), emp.getEndDate());
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
Query sqlQuery = s.getNamedQuery("EmploymentAndPerson");
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
list = sqlQuery.list();
assertEquals(1, list.size());
Object res = list.get(0);
assertClassAssignability(Map.class, res.getClass());
Map m = (Map) res;
assertEquals(2, m.size());
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
sqlQuery = s.getNamedQuery("organizationreturnproperty");
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
list = sqlQuery.list();
assertEquals(2, list.size());
m = (Map) list.get(0);
assertEquals(2, m.size());
assertTrue(m.containsKey("org"));
assertTrue(m.containsKey("emp"));
assertClassAssignability(m.get("org").getClass(), Organization.class);
if (jboss.getId() == ((Organization) m.get("org")).getId()) {
assertClassAssignability(m.get("emp").getClass(), Employment.class);
}
Map m2 = (Map) list.get(1);
assertEquals(2, m.size());
assertTrue(m2.containsKey("org"));
assertTrue(m2.containsKey("emp"));
assertClassAssignability(m2.get("org").getClass(), Organization.class);
if (jboss.getId() == ((Organization) m2.get("org")).getId()) {
assertClassAssignability(m2.get("emp").getClass(), Employment.class);
}
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
namedQuery = s.getNamedQuery("EmploymentAndPerson");
list = namedQuery.list();
assertEquals(1, list.size());
Object[] objs = (Object[]) list.get(0);
assertEquals(2, objs.length);
emp2 = (Employment) objs[0];
gavin = (Person) objs[1];
s.delete(emp2);
s.delete(jboss);
s.delete(gavin);
s.delete(ifa);
t.commit();
s.close();
}
use of java.io.Serializable in project hibernate-orm by hibernate.
the class NativeSQLQueriesTest method testScalarValues.
@Test
public void testScalarValues() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Organization ifa = new Organization("IFA");
Organization jboss = new Organization("JBoss");
Serializable idIfa = s.save(ifa);
Serializable idJBoss = s.save(jboss);
s.flush();
List result = s.getNamedQuery("orgNamesOnly").list();
assertTrue(result.contains("IFA"));
assertTrue(result.contains("JBoss"));
result = s.getNamedQuery("orgNamesOnly").setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
Map m = (Map) result.get(0);
assertEquals(2, result.size());
assertEquals(1, m.size());
assertTrue(m.containsKey("NAME"));
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
Iterator iter = s.getNamedQuery("orgNamesAndOrgs").list().iterator();
Object[] o = (Object[]) iter.next();
assertEquals("expecting 2 values", 2, o.length);
assertEquals(o[0], "IFA");
assertEquals(((Organization) o[1]).getName(), "IFA");
o = (Object[]) iter.next();
assertEquals(o[0], "JBoss");
assertEquals(((Organization) o[1]).getName(), "JBoss");
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
// test that the ordering of the results is truly based on the order in which they were defined
iter = s.getNamedQuery("orgsAndOrgNames").list().iterator();
Object[] row = (Object[]) iter.next();
assertEquals("expecting 2 values", 2, row.length);
assertEquals("expecting non-scalar result first", Organization.class, row[0].getClass());
assertEquals("expecting scalar result second", String.class, row[1].getClass());
assertEquals(((Organization) row[0]).getName(), "IFA");
assertEquals(row[1], "IFA");
row = (Object[]) iter.next();
assertEquals("expecting non-scalar result first", Organization.class, row[0].getClass());
assertEquals("expecting scalar result second", String.class, row[1].getClass());
assertEquals(((Organization) row[0]).getName(), "JBoss");
assertEquals(row[1], "JBoss");
assertFalse(iter.hasNext());
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
iter = s.getNamedQuery("orgIdsAndOrgNames").list().iterator();
o = (Object[]) iter.next();
assertEquals(o[1], "IFA");
assertEquals(o[0], idIfa);
o = (Object[]) iter.next();
assertEquals(o[1], "JBoss");
assertEquals(o[0], idJBoss);
s.delete(ifa);
s.delete(jboss);
t.commit();
s.close();
}
Aggregations