org.springframework.jdbc.support.rowset.SqlRowSet Java Examples

The following examples show how to use org.springframework.jdbc.support.rowset.SqlRowSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BatchDao.java    From appstatus with Apache License 2.0 6 votes vote down vote up
/**
 * Read batch object from result set.
 * 
 * @param srs
 * @return
 * @throws IOException
 * @throws SQLException
 */
private BdBatch mappinpBdbatch(SqlRowSet srs) throws SQLException,
		IOException {
	BdBatch bdBatch = new BdBatch();
	bdBatch.setUuid(srs.getString("UUID_BATCH"));
	bdBatch.setCurrentItem(srs.getString("ITEM"));
	bdBatch.setEndDate(srs.getDate("END_DATE"));
	bdBatch.setGroup(srs.getString("GROUP_BATCH"));
	bdBatch.setItemCount(srs.getLong("ITEMCOUNT"));
	bdBatch.setLastMessage(srs.getString("LAST_MSG"));
	bdBatch.setLastUpdate(srs.getDate("UPDATED"));
	bdBatch.setName(srs.getString("NAME_BATCH"));
	bdBatch.setProgress(srs.getFloat("PROGRESS"));
	bdBatch.setStartDate(srs.getDate("START_DATE"));
	bdBatch.setStatus(srs.getString("STATUS"));
	bdBatch.setSuccess(srs.getBoolean("SUCCESS"));

	// Clob
	Clob reject = (Clob) srs.getObject("REJECT");
	bdBatch.setReject(clobToString(reject));

	return bdBatch;
}
 
Example #2
Source File: CmsDataBackDaoImpl.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
public List<CmsField> listFields(String tablename) {
	String sql = " desc  " + tablename;
	List<CmsField> fields = new ArrayList<CmsField>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsField field = new CmsField();
		field.setName(set.getString(1));
		field.setFieldType(set.getString(2));
		field.setNullable(set.getString(3));
		field.setFieldProperty(set.getString(4));
		field.setFieldDefault(set.getString(5));
		field.setExtra(set.getString(6));
		fields.add(field);
	}
	return fields;
}
 
Example #3
Source File: HibernateTimeZoneIT.java    From alchemy with Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
public void storeOffsetTimeWithUtcConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("offset_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getOffsetTime()
        .toLocalTime()
        .atDate(LocalDate.of(1970, Month.JANUARY, 1))
        .atZone(ZoneId.systemDefault())
        .format(timeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #4
Source File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getPaymentRequestDocumentStatuses()
 */
public Map<String, String> getPaymentRequestDocumentStatuses() {
    LOG.debug("getPaymentRequestDocumentStatuses() started");
    
    Map<String, String> paymentRequestStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_PMT_RQST_STAT_T ORDER BY PMT_RQST_STAT_CD"); 

        while (statusesRowSet.next()) {
            paymentRequestStatuses.put(statusesRowSet.getString("PMT_RQST_STAT_CD"), statusesRowSet.getString("PMT_RQST_STAT_DESC"));
        }
        
        LOG.debug("getPaymentRequestDocumentStatuses() exited");
        
        return paymentRequestStatuses;
    } catch (DataAccessException dae) {
        return paymentRequestStatuses;
    }
}
 
Example #5
Source File: SelectUserActorConnectorTest.java    From FoxBPM with Apache License 2.0 6 votes vote down vote up
/**
 * 任务分配给指定用户可以多个
 * <p>1.使用场景:需要将任务分配指定用户</p>
 * <p>2.预置条件:创建一个含有人工任务并且任务分配给指定用户的流程定义并发布<p>
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源是否分配给指定用户</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/SelectUserActorConnector/SelectUserActorConnectorTest_1.bpmn" })
public void testSelectUserActorConnector() {
	Authentication.setAuthenticatedUserId("admin");
	// 启动流程
	runtimeService.startProcessInstanceByKey("SelectUserActorConnectorTest_1");
	Task task = taskService.createTaskQuery().processDefinitionKey("SelectUserActorConnectorTest_1").taskNotEnd().singleResult();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + task.getId() + "'");
	List<String> userIds = new ArrayList<String>();
	while (sqlRowSet.next()) {
		userIds.add(sqlRowSet.getString("USER_ID"));
	}
	if (!userIds.contains("a") || !userIds.contains("b")) {
		throw new FoxBPMConnectorException("选择用户连接器出现异常");
	}
}
 
Example #6
Source File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getLineItemReceivingDocumentStatuses()
 */
public Map<String, String> getLineItemReceivingDocumentStatuses() {
    LOG.debug("getLineItemReceivingDocumentStatuses() started");
    
    Map<String, String> lineItemReceivingStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_RCVNG_LN_STAT_T ORDER BY RCVNG_LN_STAT_CD"); 

        while (statusesRowSet.next()) {
            lineItemReceivingStatuses.put(statusesRowSet.getString("RCVNG_LN_STAT_CD"), statusesRowSet.getString("RCVNG_LN_STAT_DESC"));
        }
        
        LOG.debug("getLineItemReceivingDocumentStatuses() exited");
        
        return lineItemReceivingStatuses;
    } catch (DataAccessException dae) {
        return lineItemReceivingStatuses;
    }
}
 
Example #7
Source File: SelectDeptActorConnectorTest.java    From FoxBPM with Apache License 2.0 6 votes vote down vote up
/**
 * 资源共享
 * <p>1.使用场景:将任务分配给某部门(部门可以多个)</p>
 * <p>2.预置条件:<p>
 *          1.发布一条带有任务分配(分配部门)的流程定义
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源分配是否是所以人都能看得到</p>
 * <p>		2.执行完成后,相应查看foxbpm_run_taskidentitylink任务是否分配给部门</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/SelectDeptActorConnector/SelectDeptActorConnectorTest_1.bpmn" })
public void testSelectDeptActorConnector() {
	Authentication.setAuthenticatedUserId("admin");
	// 启动流程
	runtimeService.startProcessInstanceByKey("SelectDeptActorConnectorTest_1");
	Task task = taskService.createTaskQuery().processDefinitionKey("SelectDeptActorConnectorTest_1").taskNotEnd().singleResult();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + task.getId() + "'");
	List<String> userIds = new ArrayList<String>();
	while (sqlRowSet.next()) {
		userIds.add(sqlRowSet.getString("GROUP_ID"));
	}
	if (!userIds.contains("a") || !userIds.contains("b")) {
		throw new FoxBPMConnectorException("选择用户连接器出现异常");
	}
}
 
Example #8
Source File: HibernateTimeZoneIT.java    From java-microservices-examples with Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
public void storeOffsetTimeWithUtcConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("offset_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getOffsetTime()
        .toLocalTime()
        .atDate(LocalDate.of(1970, Month.JANUARY, 1))
        .atZone(ZoneId.systemDefault())
        .format(timeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #9
Source File: CmsDataDaoImpl.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
public List<CmsConstraints> listConstraints(String tablename) {
	String sql = "select constraint_name,table_name,column_name,referenced_table_name,referenced_column_name from information_schema.KEY_COLUMN_USAGE where constraint_schema='"
			+ db + "' and table_name='" + tablename + "'";
	List<CmsConstraints> constraints = new ArrayList<CmsConstraints>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsConstraints constraint = new CmsConstraints();
		constraint.setName(set.getString(1));
		constraint.setTableName(set.getString(2));
		constraint.setColumnName(set.getString(3));
		constraint.setReferencedTableName(set.getString(4));
		constraint.setReferencedColumnName(set.getString(5));
		constraints.add(constraint);
	}
	return constraints;
}
 
Example #10
Source File: HibernateTimeZoneTest.java    From ehcache3-samples with Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
public void storeOffsetTimeWithUtcConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("offset_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getOffsetTime()
        .toLocalTime()
        .atDate(LocalDate.of(1970, Month.JANUARY, 1))
        .atZone(ZoneId.systemDefault())
        .format(timeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #11
Source File: CmsDataBackDaoImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
private int getTableFieldNums(String tablename) {
	String sql = " desc  " + tablename;
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	int rownum = 0;
	while (set.next()) {
		rownum++;
	}
	return rownum;
}
 
Example #12
Source File: BatchDao.java    From appstatus with Apache License 2.0 5 votes vote down vote up
@Transactional(readOnly = true)
private List<BdBatch> fetchBdBatch(final int max, String[] status) {
	SqlRowSet srs = this.jdbcTemplate.queryForRowSet(
			insertParametersFromList(getSql(BATCH_FETCH), status),
			new Object[] { max });
	return resultSet2Batches(srs);
}
 
Example #13
Source File: HibernateTimeZoneIT.java    From alchemy with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void storeZoneDateTimeWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("zoned_date_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getZonedDateTime()
        .format(dateTimeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #14
Source File: HibernateTimeZoneIT.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
private void assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(SqlRowSet sqlRowSet, String expectedValue) {
    while (sqlRowSet.next()) {
        String dbValue = sqlRowSet.getString(1);

        assertThat(dbValue).isNotNull();
        assertThat(dbValue).isEqualTo(expectedValue);
    }
}
 
Example #15
Source File: JdbcEventStore.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean userHasAccess( SqlRowSet rowSet )
{
    if ( rowSet.wasNull() )
    {
        return true;
    }

    if ( rowSet.getString( "uga_access" ) == null && rowSet.getString( "ua_access" ) == null && rowSet.getString( "deco_publicaccess" ) == null )
    {
        return false;
    }

    return AccessStringHelper.isEnabled( rowSet.getString( "deco_publicaccess" ), AccessStringHelper.Permission.DATA_READ );
}
 
Example #16
Source File: HibernateTimeZoneIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
@Transactional
public void storeLocalTimeWithUtcConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("local_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getLocalTime()
        .atDate(LocalDate.of(1970, Month.JANUARY, 1))
        .atZone(ZoneId.systemDefault())
        .format(timeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #17
Source File: HibernateTimeZoneIT.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void storeZoneDateTimeWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("zoned_date_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getZonedDateTime()
        .format(dateTimeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #18
Source File: HibernateTimeZoneIT.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void storeLocalDateWithUtcConfigShouldBeStoredWithoutTransformation() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("local_date", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getLocalDate()
        .format(dateFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #19
Source File: JdbcRawAnalyticsManager.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Grid getRawDataValues( DataQueryParams params, Grid grid )
{
    Assert.isTrue( params.hasStartEndDate(), "Start and end dates must be specified" );

    List<DimensionalObject> dimensions = new ArrayList<>();
    dimensions.addAll( params.getDimensions() );
    dimensions.addAll( params.getOrgUnitLevelsAsDimensions() );

    if ( params.isIncludePeriodStartEndDates() )
    {
        dimensions.add( new BaseDimensionalObject( PERIOD_START_DATE_ID, DimensionType.STATIC, PERIOD_START_DATE_NAME, new ArrayList<>() ) );
        dimensions.add( new BaseDimensionalObject( PERIOD_END_DATE_ID, DimensionType.STATIC, PERIOD_END_DATE_NAME, new ArrayList<>() ) );
    }

    String sql = getSelectStatement( params, dimensions );

    log.debug( "Get raw data SQL: " + sql );

    SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );

    while ( rowSet.next() )
    {
        grid.addRow();

        for ( DimensionalObject dim : dimensions )
        {
            grid.addValue( rowSet.getString( dim.getDimensionName() ) );
        }

        grid.addValue( rowSet.getDouble( "value" ) );
    }

    return grid;
}
 
Example #20
Source File: NamedParameterJdbcTemplate.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public SqlRowSet queryForRowSet(String sql, SqlParameterSource paramSource) throws DataAccessException {
	SqlRowSet result = getJdbcOperations().query(
			getPreparedStatementCreator(sql, paramSource), new SqlRowSetResultSetExtractor());
	Assert.state(result != null, "No result");
	return result;
}
 
Example #21
Source File: RightsDataServlet.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Useful method for retrieving the label for the users
 */
private Map<Long, String> getUsers(long tenantId) throws PersistenceException {
	UserDAO dao = (UserDAO) Context.get().getBean(UserDAO.class);
	SqlRowSet set = dao.queryForRowSet(
			"select ld_id, ld_username, ld_firstname, ld_name from ld_user where ld_deleted=0 and ld_tenantid="
					+ tenantId,
			null, null);
	Map<Long, String> users = new HashMap<Long, String>();
	while (set.next())
		users.put(set.getLong(1), set.getString(4) + " " + set.getString(3) + " (" + set.getString(2) + ")");
	return users;
}
 
Example #22
Source File: HibernateTimeZoneTest.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void storeInstantWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("instant", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeFormatter.format(dateTimeWrapper.getInstant());

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #23
Source File: EndToEndTest.java    From ecs-sync with Apache License 2.0 5 votes vote down vote up
private long verifyDbObjects(JdbcTemplate jdbcTemplate, TestStorage storage, Collection<? extends SyncObject> objects) {
    Date now = new Date();
    long count = 0;
    for (SyncObject object : objects) {
        count++;
        String identifier = storage.getIdentifier(object.getRelativePath(), object.getMetadata().isDirectory());
        SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT * FROM " + storage.getOptions().getDbTable() + " WHERE target_id=?",
                identifier);
        Assert.assertTrue(rowSet.next());
        Assert.assertEquals(identifier, rowSet.getString("target_id"));
        Assert.assertEquals(object.getMetadata().isDirectory(), rowSet.getBoolean("is_directory"));
        Assert.assertEquals(object.getMetadata().getContentLength(), rowSet.getLong("size"));
        // mtime in the DB is actually pulled from the target system, so we don't know what precision it will be in
        // or if the target system's clock is in sync, but let's assume it will always be within 5 minutes
        Assert.assertTrue(Math.abs(object.getMetadata().getModificationTime().getTime() - rowSet.getLong("mtime")) < 5 * 60 * 1000);
        Assert.assertEquals(ObjectStatus.Verified.getValue(), rowSet.getString("status"));
        long transferStart = rowSet.getLong("transfer_start"), transferComplete = rowSet.getLong("transfer_complete");
        if (transferStart > 0)
            Assert.assertTrue(now.getTime() - transferStart < 10 * 60 * 1000); // less than 10 minutes ago
        if (transferComplete > 0)
            Assert.assertTrue(now.getTime() - transferComplete < 10 * 60 * 1000); // less than 10 minutes ago
        Assert.assertTrue(now.getTime() - rowSet.getLong("verify_start") < 10 * 60 * 1000); // less than 10 minutes ago
        Assert.assertTrue(now.getTime() - rowSet.getLong("verify_complete") < 10 * 60 * 1000); // less than 10 minutes ago
        Assert.assertEquals(0, rowSet.getInt("retry_count"));
        if (object.getMetadata().isDirectory())
            count += verifyDbObjects(jdbcTemplate, storage, storage.getChildren(identifier));
    }
    return count;
}
 
Example #24
Source File: HibernateTimeZoneTest.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
public void storeZoneDateTimeWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("zoned_date_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getZonedDateTime()
        .format(dateTimeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #25
Source File: HibernateTimeZoneTest.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Test
@Transactional
public void storeInstantWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("instant", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeFormatter.format(dateTimeWrapper.getInstant());

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #26
Source File: HibernateTimeZoneTest.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Test
@Transactional
public void storeLocalDateTimeWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("local_date_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getLocalDateTime()
        .atZone(ZoneId.systemDefault())
        .format(dateTimeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #27
Source File: EventTypeDbRepositoryTest.java    From nakadi with MIT License 5 votes vote down vote up
@Test
public void whenUpdateExistingEventTypeItUpdates() throws IOException {
    final EventType eventType = buildDefaultEventType();

    repository.saveEventType(eventType);

    eventType.setCategory(EventCategory.BUSINESS);
    eventType.setOwningApplication("new-application");

    repository.update(eventType);

    final int rows = template.queryForObject(
            "SELECT count(*) FROM zn_data.event_type_schema WHERE ets_event_type_name=?",
            Integer.class, eventType.getName());
    assertThat("Number of rows should increase", rows, equalTo(1));

    final SqlRowSet rs = template.queryForRowSet(
            "SELECT et_event_type_object FROM zn_data.event_type WHERE et_name=?", eventType.getName());
    rs.next();

    final EventType persisted = TestUtils.OBJECT_MAPPER.readValue(rs.getString(1), EventType.class);

    assertThat(persisted.getCategory(), equalTo(eventType.getCategory()));
    assertThat(persisted.getOwningApplication(), equalTo(eventType.getOwningApplication()));
    assertThat(persisted.getPartitionKeyFields(), equalTo(eventType.getPartitionKeyFields()));
    assertThat(persisted.getName(), equalTo(eventType.getName()));
    assertThat(persisted.getSchema().getType(), equalTo(eventType.getSchema().getType()));
    assertThat(persisted.getSchema().getSchema(), equalTo(eventType.getSchema().getSchema()));
}
 
Example #28
Source File: HibernateTimeZoneTest.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Test
@Transactional
public void storeZoneDateTimeWithUtcConfigShouldBeStoredOnGMTTimeZone() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("zoned_date_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getZonedDateTime()
        .format(dateTimeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #29
Source File: HibernateTimeZoneTest.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Test
@Transactional
public void storeLocalTimeWithUtcConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
    dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

    String request = generateSqlRequest("local_time", dateTimeWrapper.getId());
    SqlRowSet resultSet = jdbcTemplate.queryForRowSet(request);
    String expectedValue = dateTimeWrapper
        .getLocalTime()
        .atDate(LocalDate.of(1970, Month.JANUARY, 1))
        .atZone(ZoneId.systemDefault())
        .format(timeFormatter);

    assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(resultSet, expectedValue);
}
 
Example #30
Source File: HibernateTimeZoneTest.java    From ehcache3-samples with Apache License 2.0 5 votes vote down vote up
private void assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone(SqlRowSet sqlRowSet, String expectedValue) {
    while (sqlRowSet.next()) {
        String dbValue = sqlRowSet.getString(1);

        assertThat(dbValue).isNotNull();
        assertThat(dbValue).isEqualTo(expectedValue);
    }
}