@Override public CassandraEndpointRegistration save(EndpointRegistrationDto endpointRegistration) { LOG.debug("Saving [{}]", endpointRegistration.toString()); return this.save(new CassandraEndpointRegistration(endpointRegistration)); }
@Override public CassandraEndpointRegistration save(CassandraEndpointRegistration object) { if (isBlank(object.getId())) { object.generateId(); } object = super.save(object); List<Statement> statements = new ArrayList<>(); statements.add(this.getSaveQuery(object)); if (object.getEndpointId() != null) { statements.add( this.byEndpointId.getSaveQuery( CassandraEpRegistrationByEndpointId.fromEndpointRegistration(object))); } this.executeBatch(statements.toArray(new Statement[statements.size()])); return object; }
@Test public void dataConversionTest() throws Exception { EndpointRegistrationDto endpointRegistrationDto = new EndpointRegistrationDto("1", "2", "3", 42, "test"); CassandraEndpointRegistration cassandraEndpointRegistration = new CassandraEndpointRegistration(endpointRegistrationDto); Assert.assertEquals(endpointRegistrationDto, cassandraEndpointRegistration.toDto()); } }
protected EndpointRegistrationDto generateEndpointRegistration( String applicationId, String endpointId, String credentialsId, Integer serverProfileVersion, String serverProfileBody) { EndpointRegistrationDto endpointRegistration = new EndpointRegistrationDto(); endpointRegistration.setApplicationId(applicationId); endpointRegistration.setEndpointId(endpointId); endpointRegistration.setCredentialsId(credentialsId); endpointRegistration.setServerProfileVersion(serverProfileVersion); endpointRegistration.setServerProfileBody(serverProfileBody); return this.endpointRegistrationDao.save(endpointRegistration).toDto(); }