Skip to content

Instantly share code, notes, and snippets.

View lhauspie's full-sized avatar

Logan HAUSPIE lhauspie

View GitHub Profile
{
"basics": {
"name": "Tester FOO",
"picture": "https://avataaar.welovedevs.com/png/?accessoriesType=Blank&eyeType=Wink&eyebrowType=DefaultNatural&facialHairColor=BrownDark&facialHairType=BeardMedium&mouthType=Smile&skinColor=Tanned&topType=NoHair&clotheType=GraphicShirt&clotheColor=W3D&graphicType=W3DLogo",
"title": "Auxiliaire de pilotage",
"summary": "Je suis un Tester FOO",
"location": {
"countryCode": "BR"
}
},
version: 2.1
jobs:
# ====================================================================================
share_env_var_between_steps_failure:
docker:
- image: circleci/openjdk:8-jdk
steps:
- run: MY_VAR='Hello, World!'
- run: echo "$MY_VAR"
use std::collections::HashMap;
fn main() {
println!("Hello, world!");
}
struct Dependencies {
deps : HashMap<String, Vec<String>>
}
WITH upd AS (
UPDATE target t
SET counter = t.counter + s.counter,
FROM source s
WHERE t.id = s.id
RETURNING s.id
)
INSERT INTO target(id, counter)
SELECT id, sum(counter)
FROM source s LEFT JOIN upd t USING(id)
BEGIN;
DROP TABLE critical_data;
ROLLBACK;
@lhauspie
lhauspie / ProductRepositoryTest.java
Created August 22, 2017 23:40
Cumul Test unitaire et d'intégration
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProductRepositoryTest {
@Autowired
private ProductRepository productRepo;
@SpyBean
private MongoTemplate mongoTemplate;
@Test
@lhauspie
lhauspie / pom.xml
Created August 22, 2017 23:21
pom.xml file of a Spring Boot application with MongoDB + embeded
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[...]
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
[...]
@lhauspie
lhauspie / ProductRepositoryIntegrationTest.log
Created August 22, 2017 23:13
Echec double lancement test d'intégration
ava.lang.AssertionError:
Expected size:<0> but was:<1> in:
<[Product(id=599cb8cde50e2262d67575c1, code=CODE, label=LABEL, description=DESCRIPTION, price=1234.0)]>
at com.github.lhauspie.mongodb.junit.demo.repository.ProductRepositoryIntegrationTest.searchProductTest(ProductRepositoryIntegrationTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
@lhauspie
lhauspie / ProductRepositoryIntegrationTest.java
Created August 22, 2017 23:01
Test d’intégration du Custom Repository produit
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProductRepositoryIntegrationTest {
@Autowired
private ProductRepository productRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Test
@lhauspie
lhauspie / MockedMongoConfig.java
Created August 22, 2017 22:45
Définition d'un configuration de test spécifique pour Mocker le MongoTemplate
@TestConfiguration
public class MockedMongoConfig {
@Bean
public MongoTemplate mongoTemplate() {
MongoMappingContext mappingContext = new MongoMappingContext();
MongoConverter mongoConverter = Mockito.mock(MongoConverter.class);
Mockito.when(mongoConverter.getMappingContext()).then(ignoredInvocation -> mappingContext);