[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377050258
 
 

 ##
 File path: 
modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
+ */
+@Bean
+public CacheNamesBean cacheNames() {
+CacheNamesBean bean = new CacheNamesBean();
+bean.setPersonCacheName("PersonCache");
+return bean;
 
 Review comment:
   Need empty line before :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377048967
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
 
 Review comment:
   Need dots in the end :)
   
   ```suggestion
* The bean with cache names.
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377049534
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,41 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = executeExpression(annotation.cacheName());
 
-repoToCache.put(repoItf, annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
 
 Review comment:
   ```suggestion
   @NotNull private String evaluateExpression(String  spelExpression) {
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377048967
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
 
 Review comment:
   Need dots in the end :)
   
   ```suggestion
* The bean with cache names.
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377049114
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
+ */
+@Bean
+public CacheNamesBean cacheNames() {
+CacheNamesBean bean = new CacheNamesBean();
+bean.setPersonCacheName("PersonCache");
+return bean;
 
 Review comment:
   Need empty line before.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377047999
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
 
 Review comment:
   ```suggestion
   @NotNull private String evaluateExpression(String  spelExpression) {
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377050258
 
 

 ##
 File path: 
modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
+ */
+@Bean
+public CacheNamesBean cacheNames() {
+CacheNamesBean bean = new CacheNamesBean();
+bean.setPersonCacheName("PersonCache");
+return bean;
 
 Review comment:
   Empty line before :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377048446
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
+StandardBeanExpressionResolver resolver = new 
StandardBeanExpressionResolver();
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
 
 Review comment:
   Looks like we don't use `ec` variable 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377047832
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
 
 Review comment:
   ```suggestion
*  Evaluate a SpEL expression.
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377046206
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfExpressionTest.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonExpressionRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using repository which is configured by Spring EL
+ */
+public class IgniteSpringDataCrudSelfExpressionTest extends 
GridCommonAbstractTest {
+/** Repository. */
+private static PersonExpressionRepository repo;
+
+/** Context. */
+private static AnnotationConfigApplicationContext ctx;
+
+/** Number of entries to store */
+private static int CACHE_SIZE = 1000;
+
+/** {@inheritDoc} */
+@Override protected void beforeTestsStarted() throws Exception {
+super.beforeTestsStarted();
+
+ctx = new AnnotationConfigApplicationContext();
+
+ctx.register(ApplicationConfiguration.class);
+
+ctx.refresh();
+
+repo = ctx.getBean(PersonExpressionRepository.class);
+}
+
+/** {@inheritDoc} */
+@Override protected void beforeTest() throws Exception {
+super.beforeTest();
+
+fillInRepository();
+
+assertEquals(CACHE_SIZE, repo.count());
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTest() throws Exception {
+repo.deleteAll();
+
+assertEquals(0, repo.count());
+
+super.afterTest();
+}
+
+/**
+ *
+ */
+private void fillInRepository() {
+for (int i = 0; i < CACHE_SIZE - 5; i++) {
+repo.save(i, new Person("person" + Integer.toHexString(i),
+"lastName" + Integer.toHexString((i + 16) % 256)));
+}
+
+repo.save((int) repo.count(), new Person("uniquePerson", 
"uniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTestsStopped() throws Exception {
+ctx.destroy();
+}
+@Test
+public void testPutGet() {
+Person person = new Person("some_name", "some_surname");
+
+int id = CACHE_SIZE + 1;
+
+assertEquals(person, repo.save(id, person));
+
+assertTrue(repo.existsById(id));
+
+assertEquals(person, repo.findById(id).get());
+
+try {
+repo.save(person);
+
+fail("Managed to save a Person without ID");
+}
+catch (UnsupportedOperationException e) {
+//excepted
 
 Review comment:
   I think we should use it :) With `GridTestUtils.assertThrows` we can assert 
error message:
   
   ```java
   GridTestUtils .assertThrows(
   null,
   () -> repo.save(person),
   UnsupportedOperationException.class,
   "Use IgniteRepository.save(key,value) method instead."
   );
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376270365
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
 
 Review comment:
   Let's move all this code, into separate method.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376263415
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
+Expression expression = 
parser.parseExpression(annotation.cacheName());
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
+cacheName = (String)expression.getValue(ec);
+}
+repoToCache.put(repoItf, cacheName);
 
 repoToCache.put(repoItf, annotation.cacheName());
 
 return super.getRepositoryMetadata(repoItf);
 }
+/**
+ * The method tryes to identify SpEL extression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ * @param expression
+ * @return
+ */
+
 
 Review comment:
   Remove empty line :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376263674
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
+Expression expression = 
parser.parseExpression(annotation.cacheName());
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
+cacheName = (String)expression.getValue(ec);
+}
+repoToCache.put(repoItf, cacheName);
 
 repoToCache.put(repoItf, annotation.cacheName());
 
 return super.getRepositoryMetadata(repoItf);
 }
+/**
+ * The method tryes to identify SpEL extression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ * @param expression
+ * @return
+ */
+
+private boolean looksLikeExpression(String expression) {
 
 Review comment:
   Maybe rename  to: isSpelExpression ?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376269394
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,10 +117,36 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+//
https://stackoverflow.com/questions/11616316/programmatically-evaluate-a-bean-expression-with-spring-expression-language
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
 
 Review comment:
   One line if statements must be without brackets:
   
   ```java
   if (!looksLikeExpression(annotation.cacheName()))
cacheName = annotation.cacheName();
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376268742
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -44,6 +49,8 @@
 public class IgniteRepositoryFactory extends RepositoryFactorySupport {
 /** Ignite instance */
 private Ignite ignite;
+/** Spring application context */
 
 Review comment:
   Empty line needed


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376269822
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
 
 Review comment:
   One line if statements should be without brackets:
   
   ```java
   if (!looksLikeExpression(annotation.cacheName()))
cacheName = annotation.cacheName();
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376267199
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,13 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+@Bean
+public CacheNamesBean cacheNames() {
 
 Review comment:
   Missing javadoc.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376266938
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfExpressionTest.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonExpressionRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using repository which is configured by Spring EL
+ */
+public class IgniteSpringDataCrudSelfExpressionTest extends 
GridCommonAbstractTest {
+/** Repository. */
+private static PersonExpressionRepository repo;
+
+/** Context. */
+private static AnnotationConfigApplicationContext ctx;
+
+/** Number of entries to store */
+private static int CACHE_SIZE = 1000;
+
+/** {@inheritDoc} */
+@Override protected void beforeTestsStarted() throws Exception {
+super.beforeTestsStarted();
+
+ctx = new AnnotationConfigApplicationContext();
+
+ctx.register(ApplicationConfiguration.class);
+
+ctx.refresh();
+
+repo = ctx.getBean(PersonExpressionRepository.class);
+}
+
+/** {@inheritDoc} */
+@Override protected void beforeTest() throws Exception {
+super.beforeTest();
+
+fillInRepository();
+
+assertEquals(CACHE_SIZE, repo.count());
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTest() throws Exception {
+repo.deleteAll();
+
+assertEquals(0, repo.count());
+
+super.afterTest();
+}
+
+/**
+ *
+ */
+private void fillInRepository() {
+for (int i = 0; i < CACHE_SIZE - 5; i++) {
+repo.save(i, new Person("person" + Integer.toHexString(i),
+"lastName" + Integer.toHexString((i + 16) % 256)));
+}
+
+repo.save((int) repo.count(), new Person("uniquePerson", 
"uniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTestsStopped() throws Exception {
+ctx.destroy();
+}
+@Test
+public void testPutGet() {
+Person person = new Person("some_name", "some_surname");
+
+int id = CACHE_SIZE + 1;
+
+assertEquals(person, repo.save(id, person));
+
+assertTrue(repo.existsById(id));
+
+assertEquals(person, repo.findById(id).get());
+
+try {
+repo.save(person);
+
+fail("Managed to save a Person without ID");
+}
+catch (UnsupportedOperationException e) {
+//excepted
 
 Review comment:
   You can use  `GridTestUtils.assertThrows` for asserts.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] smoldachev commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
smoldachev commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376267413
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/CacheNamesBean.java
 ##
 @@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springdata.misc;
+
+public class CacheNamesBean {
 
 Review comment:
   Missing javadoc. Please check that all methods and classes has javadoc :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services