congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
EndpointSpecificConfigurationDao
Code IndexAdd Tabnine to your IDE (free)

How to use
EndpointSpecificConfigurationDao
in
org.kaaproject.kaa.server.common.dao.impl

Best Java code snippets using org.kaaproject.kaa.server.common.dao.impl.EndpointSpecificConfigurationDao (Showing top 20 results out of 315)

origin: kaaproject/kaa

@Test
public void testRemoveByEndpointKeyHashAndConfigurationVersion() throws Exception {
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 3);
 endpointSpecificConfigurationDao.removeByEndpointKeyHashAndConfigurationVersion(KEY, 0);
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 2);
 Assert.assertTrue(endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 0) == null);
}
origin: kaaproject/kaa

 @After
 public void tearDown() throws Exception {
  endpointSpecificConfigurationDao.removeAll();
 }
}
origin: kaaproject/kaa

@Test
public void testShouldDeleteActiveConfigurationByEndpointKeyHash() {
 when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(generateProfile());
 when(daoMock.findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION)).thenReturn(configuration);
 when(configuration.toDto()).thenReturn(configurationDto);
 when(configurationDto.getConfigurationSchemaVersion()).thenReturn(CONF_VERSION);
 Assert.assertTrue(SERVICE.deleteActiveConfigurationByEndpointKeyHash(KEY).isPresent());
 verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY);
 verify(daoMock).findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
 verify(daoMock).removeByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
}
origin: kaaproject/kaa

@Test(expected = KaaOptimisticLockingFailureException.class)
public void testLocking() throws Throwable {
 List<Future<?>> tasks = new ArrayList<>();
 for (int i = 0; i < 100; i++) {
  tasks.add(executorService.submit((Runnable) () -> {
   endpointSpecificConfigurationDao.save(saved1);
  }));
 }
 for (Future future : tasks) {
  try {
   future.get();
  } catch (ExecutionException ex) {
   throw ex.getCause();
  }
 }
}
origin: kaaproject/kaa

@Override
public Optional<EndpointSpecificConfigurationDto> findActiveConfigurationByEndpointKeyHash(byte[] endpointKeyHash) {
 LOG.debug("Looking for active endpoint specific configuration by EP key hash {}", endpointKeyHash);
 EndpointProfileDto profileDto = getEndpointProfileDto(endpointKeyHash);
 if (profileDto == null) {
  return Optional.empty();
 }
 EndpointSpecificConfiguration configuration = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(endpointKeyHash,
   profileDto.getConfigurationVersion());
 return Optional.ofNullable(configuration).map(ToDto::toDto);
}
origin: kaaproject/kaa

@Test
public void testFindByEndpointKeyHashAndConfigurationVersion() throws Exception {
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 3);
 EndpointSpecificConfigurationDto found1 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 0).toDto();
 EndpointSpecificConfigurationDto found2 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 1).toDto();
 EndpointSpecificConfigurationDto found3 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY_2, 0).toDto();
 EndpointSpecificConfiguration found4 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY_2, 4);
 Assert.assertEquals(saved1, found1);
 Assert.assertEquals(saved2, found2);
 Assert.assertEquals(saved3, found3);
 Assert.assertNull(found4);
}
origin: kaaproject/kaa

@Override
public Optional<EndpointSpecificConfigurationDto> deleteByEndpointKeyHashAndConfSchemaVersion(byte[] endpointKeyHash, Integer confSchemaVersion) {
 Optional<EndpointSpecificConfigurationDto> configuration = findByEndpointKeyHashAndConfSchemaVersion(endpointKeyHash, confSchemaVersion);
 if (configuration.isPresent()) {
  endpointSpecificConfigurationDao.removeByEndpointKeyHashAndConfigurationVersion(endpointKeyHash, confSchemaVersion);
 }
 return configuration;
}
origin: kaaproject/kaa

@Test
public void testShouldDeleteByEndpointKeyHashAndConfSchemaVersion() {
 EndpointProfileDto profile = generateProfile();
 profile.setConfigurationVersion(0);
 when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(profile);
 when(daoMock.findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION)).thenReturn(configuration);
 when(configuration.toDto()).thenReturn(configurationDto);
 when(configurationServiceMock.findConfSchemaByAppIdAndVersion(APP_ID, CONF_VERSION)).thenReturn(new ConfigurationSchemaDto());
 when(configurationDto.getConfigurationSchemaVersion()).thenReturn(CONF_VERSION);
 Assert.assertTrue(SERVICE.deleteByEndpointKeyHashAndConfSchemaVersion(KEY, CONF_VERSION).isPresent());
 verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY);
 verify(daoMock).findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
 verify(daoMock).removeByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
 verify(configurationServiceMock).findConfSchemaByAppIdAndVersion(APP_ID, CONF_VERSION);
}
origin: kaaproject/kaa

@Test(expected = KaaOptimisticLockingFailureException.class)
public void testLocking() throws Throwable {
 List<Future<?>> tasks = new ArrayList<>();
 for (int i = 0; i < 100; i++) {
  tasks.add(executorService.submit((Runnable) () -> {
   endpointSpecificConfigurationDao.save(saved1);
  }));
 }
 for (Future future : tasks) {
  try {
   future.get();
  } catch (ExecutionException ex) {
   throw ex.getCause();
  }
 }
}
origin: kaaproject/kaa

@Override
public Optional<EndpointSpecificConfigurationDto> findActiveConfigurationByEndpointProfile(EndpointProfileDto endpointProfileDto) {
 byte[] endpointKeyHash = endpointProfileDto.getEndpointKeyHash();
 int configurationVersion = endpointProfileDto.getConfigurationVersion();
 EndpointSpecificConfiguration configuration = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(endpointKeyHash,
   configurationVersion);
 return Optional.ofNullable(configuration).map(ToDto::toDto);
}
origin: kaaproject/kaa

@Test
public void testFindByEndpointKeyHashAndConfigurationVersion() throws Exception {
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 3);
 EndpointSpecificConfigurationDto found1 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 0).toDto();
 EndpointSpecificConfigurationDto found2 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 1).toDto();
 EndpointSpecificConfigurationDto found3 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY_2, 0).toDto();
 EndpointSpecificConfiguration found4 = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY_2, 4);
 Assert.assertEquals(saved1, found1);
 Assert.assertEquals(saved2, found2);
 Assert.assertEquals(saved3, found3);
 Assert.assertNull(found4);
}
origin: kaaproject/kaa

@Override
public Optional<EndpointSpecificConfigurationDto> deleteActiveConfigurationByEndpointKeyHash(byte[] endpointKeyHash) {
 Optional<EndpointSpecificConfigurationDto> configuration = findActiveConfigurationByEndpointKeyHash(endpointKeyHash);
 if (configuration.isPresent()) {
  int confSchemaVersion = configuration.get().getConfigurationSchemaVersion();
  endpointSpecificConfigurationDao.removeByEndpointKeyHashAndConfigurationVersion(endpointKeyHash, confSchemaVersion);
 }
 return configuration;
}
origin: kaaproject/kaa

@Test
public void testRemoveByEndpointKeyHashAndConfigurationVersion() throws Exception {
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 3);
 endpointSpecificConfigurationDao.removeByEndpointKeyHashAndConfigurationVersion(KEY, 0);
 Assert.assertTrue(endpointSpecificConfigurationDao.find().size() == 2);
 Assert.assertTrue(endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(KEY, 0) == null);
}
origin: kaaproject/kaa

 protected EndpointSpecificConfigurationDto generateEpsConfigurationDto(byte[] endpointKeyHash,
                                     Integer configurationVersion,
                                     String configuration,
                                     Long version) {
  EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(endpointKeyHash, configurationVersion, configuration, version);
  return endpointSpecificConfigurationDao.save(dto).toDto();
 }
}
origin: kaaproject/kaa

@Override
public Optional<EndpointSpecificConfigurationDto> findByEndpointKeyHashAndConfSchemaVersion(byte[] endpointKeyHash, Integer confSchemaVersion) {
 LOG.debug("Looking for endpoint specific configuration by EP key hash {} and confSchemaVersion", endpointKeyHash, confSchemaVersion);
 validateNotNull(confSchemaVersion, "Configuration schema version is required");
 EndpointProfileDto profileDto = getEndpointProfileDto(endpointKeyHash);
 if (profileDto == null) {
  return Optional.empty();
 }
 validateConfSchemaVersion(profileDto.getApplicationId(), confSchemaVersion);
 EndpointSpecificConfiguration configuration = endpointSpecificConfigurationDao.findByEndpointKeyHashAndConfigurationVersion(endpointKeyHash,
   confSchemaVersion);
 return Optional.ofNullable(configuration).map(ToDto::toDto);
}
origin: kaaproject/kaa

 @After
 public void tearDown() throws Exception {
  endpointSpecificConfigurationDao.removeAll();
 }
}
origin: kaaproject/kaa

 /**
  * Constructs an endpoint specific configuration with the information provided and
  * saves it to the database.
  *
  * @param endpointKeyHash      The endpoint key hash
  * @param configurationVersion The endpoint configuration version
  * @param configuration        The configuration body
  * @param version              The endpoint specific configuration version
  * @return saved endpoint specific configuration
  */
 protected EndpointSpecificConfigurationDto generateEndpointSpecificConfigurationDto(byte[] endpointKeyHash, Integer configurationVersion, String configuration, Long version) {
  EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(endpointKeyHash, configurationVersion, configuration, version);
  return endpointSpecificConfigurationDao.save(dto).toDto();
 }
}
origin: kaaproject/kaa

@Test
public void testShouldActiveConfigurationByEndpointProfile() {
 when(daoMock.findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION)).thenReturn(configuration);
 when(configuration.toDto()).thenReturn(new EndpointSpecificConfigurationDto());
 Assert.assertTrue(SERVICE.findActiveConfigurationByEndpointProfile(generateProfile()).isPresent());
 verify(daoMock).findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
}
origin: kaaproject/kaa

@Test
public void testShouldSaveWithActiveConfigSchemaVersion() {
 EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto();
 dto.setConfigurationSchemaVersion(null);
 dto.setEndpointKeyHash(KEY);
 dto.setConfiguration(CONFIG_BODY);
 when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(generateProfile());
 when(configurationServiceMock.normalizeAccordingToOverrideConfigurationSchema(APP_ID, CONF_VERSION, CONFIG_BODY)).thenReturn("valid body");
 when(daoMock.save(dto)).thenReturn(configuration);
 when(configuration.toDto()).thenReturn(new EndpointSpecificConfigurationDto());
 Assert.assertTrue(SERVICE.save(dto) != null);
 verify(configurationServiceMock).normalizeAccordingToOverrideConfigurationSchema(APP_ID, CONF_VERSION, CONFIG_BODY);
 verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY);
 verify(daoMock).save(dto);
}
origin: kaaproject/kaa

@Test
public void testShouldFindActiveConfigurationByEndpointKeyHash() {
 EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto();
 dto.setConfigurationSchemaVersion(CONF_VERSION);
 when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(generateProfile());
 when(daoMock.findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION)).thenReturn(configuration);
 when(configuration.toDto()).thenReturn(dto);
 Assert.assertTrue(SERVICE.findActiveConfigurationByEndpointKeyHash(KEY).isPresent());
 verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY);
 verify(daoMock).findByEndpointKeyHashAndConfigurationVersion(KEY, CONF_VERSION);
}
org.kaaproject.kaa.server.common.dao.implEndpointSpecificConfigurationDao

Most used methods

  • findByEndpointKeyHashAndConfigurationVersion
  • removeByEndpointKeyHashAndConfigurationVersion
  • save
  • find
  • removeAll

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Menu (java.awt)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now