Search in sources :

Example 21 with Serializable

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);
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) SelectionResults(com.linkedin.pinot.common.response.broker.SelectionResults) Test(org.testng.annotations.Test)

Example 22 with Serializable

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);
}
Also used : Serializable(java.io.Serializable) SelectionOperatorService(com.linkedin.pinot.core.query.selection.SelectionOperatorService) SelectionResults(com.linkedin.pinot.common.response.broker.SelectionResults) Test(org.testng.annotations.Test)

Example 23 with Serializable

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());
}
Also used : Serializable(java.io.Serializable) Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Example 24 with Serializable

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();
}
Also used : Serializable(java.io.Serializable) Organization(org.hibernate.test.sql.hand.Organization) Transaction(org.hibernate.Transaction) SQLQuery(org.hibernate.SQLQuery) Query(org.hibernate.Query) Employment(org.hibernate.test.sql.hand.Employment) List(java.util.List) Person(org.hibernate.test.sql.hand.Person) Map(java.util.Map) HashMap(java.util.HashMap) Session(org.hibernate.Session) Test(org.junit.Test)

Example 25 with Serializable

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();
}
Also used : Serializable(java.io.Serializable) Organization(org.hibernate.test.sql.hand.Organization) Transaction(org.hibernate.Transaction) Iterator(java.util.Iterator) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

Serializable (java.io.Serializable)3100 Test (org.junit.Test)906 HashMap (java.util.HashMap)789 ArrayList (java.util.ArrayList)420 Map (java.util.Map)370 List (java.util.List)208 QName (org.alfresco.service.namespace.QName)197 IOException (java.io.IOException)174 Metacard (ddf.catalog.data.Metacard)145 NodeRef (org.alfresco.service.cmr.repository.NodeRef)135 LinkedHashMap (java.util.LinkedHashMap)128 HashSet (java.util.HashSet)122 Date (java.util.Date)114 ByteArrayInputStream (java.io.ByteArrayInputStream)82 ParserContext (org.mvel2.ParserContext)82 Set (java.util.Set)80 File (java.io.File)75 ObjectInputStream (java.io.ObjectInputStream)65 Session (org.hibernate.Session)65 URI (java.net.URI)64