@Test public void test_should_persist_createMeterStatus_to_db() { final MeterStatusReq meterStatusRequest = meterStatusRepository.create(getMeterStatusRequest()); assertThat(meterStatusRequest.getMeterStatus().size()).isEqualTo(2); }
public MeterStatusReq create(final MeterStatusReq meterStatusRequest) { final List<MeterStatus> meterStatuses = meterStatusRequest.getMeterStatus(); final List<Map<String, Object>> batchValues = new ArrayList<>(meterStatuses.size()); for (final MeterStatus meterStatus : meterStatuses) batchValues.add(new MapSqlParameterSource("id", Long.valueOf(meterStatus.getCode())) .addValue("code", meterStatus.getCode()).addValue("status", meterStatus.getMeterStatus()) .addValue("active", meterStatus.getActive()) .addValue("description", meterStatus.getDescription()) .addValue("createdby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantId", meterStatus.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(meterStatusQueryBuilder.getCreateMeterStatusQuery(), batchValues.toArray(new Map[meterStatuses.size()])); return meterStatusRequest; }
MeterStatusRepository { public MeterStatusReq create(final MeterStatusReq meterStatusRequest) { final List<MeterStatus> meterStatuses = meterStatusRequest.getMeterStatus(); final List<Map<String, Object>> batchValues = new ArrayList<>(meterStatuses.size()); for (final MeterStatus meterStatus : meterStatuses) batchValues.add(new MapSqlParameterSource("id", Long.valueOf(meterStatus.getCode())) .addValue("code", meterStatus.getCode()).addValue("status", meterStatus.getMeterStatus()) .addValue("active", meterStatus.getActive()) .addValue("description", meterStatus.getDescription()) .addValue("createdby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantId", meterStatus.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(meterStatusQueryBuilder.getCreateMeterStatusQuery(), batchValues.toArray(new Map[meterStatuses.size()])); return meterStatusRequest; } }
MeterStatusRepository { public MeterStatusReq create(final MeterStatusReq meterStatusRequest) { final List<MeterStatus> meterStatuses = meterStatusRequest.getMeterStatus(); final List<Map<String, Object>> batchValues = new ArrayList<>(meterStatuses.size()); for (final MeterStatus meterStatus : meterStatuses) batchValues.add(new MapSqlParameterSource("id", Long.valueOf(meterStatus.getCode())) .addValue("code", meterStatus.getCode()).addValue("status", meterStatus.getMeterStatus()) .addValue("active", meterStatus.getActive()) .addValue("description", meterStatus.getDescription()) .addValue("createdby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantId", meterStatus.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(meterStatusQueryBuilder.getCreateMeterStatusQuery(), batchValues.toArray(new Map[meterStatuses.size()])); return meterStatusRequest; }  }
MeterStatusRepository { public MeterStatusReq create(final MeterStatusReq meterStatusRequest) { final List<MeterStatus> meterStatuses = meterStatusRequest.getMeterStatus(); final List<Map<String, Object>> batchValues = new ArrayList<>(meterStatuses.size()); for (final MeterStatus meterStatus : meterStatuses) batchValues.add(new MapSqlParameterSource("id", Long.valueOf(meterStatus.getCode())) .addValue("code", meterStatus.getCode()).addValue("status", meterStatus.getMeterStatus()) .addValue("active", meterStatus.getActive()) .addValue("description", meterStatus.getDescription()) .addValue("createdby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantId", meterStatus.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(meterStatusQueryBuilder.getCreateMeterStatusQuery(), batchValues.toArray(new Map[meterStatuses.size()])); return meterStatusRequest; }  List<MeterStatus> pushCreateToQueue(final MeterStatusReq meterStatusReq); MeterStatusReq create(final MeterStatusReq meterStatusRequest); List<MeterStatus> pushUpdateToQueue(final MeterStatusReq meterStatusRequest); MeterStatusReq update(final MeterStatusReq meterStatusRequest); List<MeterStatus> getMeterStatusByCriteria(final MeterStatusGetRequest meterStatusGetRequest); }
MeterStatusRepository { public MeterStatusReq create(final MeterStatusReq meterStatusRequest) { final List<MeterStatus> meterStatuses = meterStatusRequest.getMeterStatus(); final List<Map<String, Object>> batchValues = new ArrayList<>(meterStatuses.size()); for (final MeterStatus meterStatus : meterStatuses) batchValues.add(new MapSqlParameterSource("id", Long.valueOf(meterStatus.getCode())) .addValue("code", meterStatus.getCode()).addValue("status", meterStatus.getMeterStatus()) .addValue("active", meterStatus.getActive()) .addValue("description", meterStatus.getDescription()) .addValue("createdby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", meterStatusRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantId", meterStatus.getTenantId()) .getValues()); namedParameterJdbcTemplate.batchUpdate(meterStatusQueryBuilder.getCreateMeterStatusQuery(), batchValues.toArray(new Map[meterStatuses.size()])); return meterStatusRequest; }  List<MeterStatus> pushCreateToQueue(final MeterStatusReq meterStatusReq); MeterStatusReq create(final MeterStatusReq meterStatusRequest); List<MeterStatus> pushUpdateToQueue(final MeterStatusReq meterStatusRequest); MeterStatusReq update(final MeterStatusReq meterStatusRequest); List<MeterStatus> getMeterStatusByCriteria(final MeterStatusGetRequest meterStatusGetRequest); static final Logger logger; }