-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert spring-data tests from groovy to java (#8124)
Related to #7195. Converts spring data instrumentation tests from groovy to java.
- Loading branch information
Showing
6 changed files
with
432 additions
and
411 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
...ntation/spring/spring-data/spring-data-1.8/javaagent/src/test/groovy/SpringJpaTest.groovy
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...rumentation/spring/spring-data/spring-data-1.8/javaagent/src/test/java/SprintJpaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import java.util.List; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
import spring.jpa.JpaCustomer; | ||
import spring.jpa.JpaCustomerRepository; | ||
import spring.jpa.JpaPersistenceConfig; | ||
|
||
public class SprintJpaTest extends AbstractSpringJpaTest<JpaCustomer, JpaCustomerRepository> { | ||
|
||
@Override | ||
JpaCustomer newCustomer(String firstName, String lastName) { | ||
return new JpaCustomer(firstName, lastName); | ||
} | ||
|
||
@Override | ||
Long id(JpaCustomer customer) { | ||
return customer.getId(); | ||
} | ||
|
||
@Override | ||
void setFirstName(JpaCustomer customer, String firstName) { | ||
customer.setFirstName(firstName); | ||
} | ||
|
||
@Override | ||
Class<JpaCustomerRepository> repositoryClass() { | ||
return JpaCustomerRepository.class; | ||
} | ||
|
||
@Override | ||
JpaCustomerRepository repository() { | ||
AnnotationConfigApplicationContext context = | ||
new AnnotationConfigApplicationContext(JpaPersistenceConfig.class); | ||
JpaCustomerRepository repo = context.getBean(JpaCustomerRepository.class); | ||
|
||
// when Spring JPA sets up, it issues metadata queries -- clear those traces | ||
clearData(); | ||
|
||
return repo; | ||
} | ||
|
||
@Override | ||
List<JpaCustomer> findByLastName(JpaCustomerRepository repository, String lastName) { | ||
return repository.findByLastName(lastName); | ||
} | ||
|
||
@Override | ||
List<JpaCustomer> findSpecialCustomers(JpaCustomerRepository repository) { | ||
return repository.findSpecialCustomers(); | ||
} | ||
} |
56 changes: 0 additions & 56 deletions
56
...mentation/spring/spring-data/spring-data-3.0/testing/src/test/groovy/SpringJpaTest.groovy
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
instrumentation/spring/spring-data/spring-data-3.0/testing/src/test/java/SpringJpaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import java.util.List; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
import spring.jpa.JpaCustomer; | ||
import spring.jpa.JpaCustomerRepository; | ||
import spring.jpa.JpaPersistenceConfig; | ||
|
||
public class SpringJpaTest extends AbstractSpringJpaTest<JpaCustomer, JpaCustomerRepository> { | ||
|
||
@Override | ||
JpaCustomer newCustomer(String firstName, String lastName) { | ||
return new JpaCustomer(firstName, lastName); | ||
} | ||
|
||
@Override | ||
Long id(JpaCustomer customer) { | ||
return customer.getId(); | ||
} | ||
|
||
@Override | ||
void setFirstName(JpaCustomer customer, String firstName) { | ||
customer.setFirstName(firstName); | ||
} | ||
|
||
@Override | ||
Class<JpaCustomerRepository> repositoryClass() { | ||
return JpaCustomerRepository.class; | ||
} | ||
|
||
@Override | ||
JpaCustomerRepository repository() { | ||
AnnotationConfigApplicationContext context = | ||
new AnnotationConfigApplicationContext(JpaPersistenceConfig.class); | ||
JpaCustomerRepository repo = context.getBean(JpaCustomerRepository.class); | ||
|
||
// when Spring JPA sets up, it issues metadata queries -- clear those traces | ||
clearData(); | ||
|
||
return repo; | ||
} | ||
|
||
@Override | ||
List<JpaCustomer> findByLastName(JpaCustomerRepository repository, String lastName) { | ||
return repository.findByLastName(lastName); | ||
} | ||
|
||
@Override | ||
List<JpaCustomer> findSpecialCustomers(JpaCustomerRepository repository) { | ||
return repository.findSpecialCustomers(); | ||
} | ||
} |
Oops, something went wrong.