Skip to content

Instantly share code, notes, and snippets.

Un problème de type...

Dans cet exemple, un client appelle une ressource protégée. Mais quand on appelle /hello, une 500 est renvoyée. En analysant, la 500 provient d'une 401 sur la ressource protégée.

@RestController
public class ClientController {
    @GetMapping("/hello")
    public ResponseEntity<String> hello() {
@thieux
thieux / SocleDemo.java
Last active November 21, 2019 16:07
Démontration d'un système de plugin en Java avec deux styles : interface et annotation
package com.mathieupauly.javacoursesamples.plugin;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@thieux
thieux / IndirectListTest.java
Last active October 11, 2019 13:00
Shows that IndirectList (EclipseLink) does not respect Stream contract
package com.example.demo;
import org.eclipse.persistence.indirection.IndirectList;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@thieux
thieux / pom.xml
Created October 17, 2018 08:01
JUnit5 maven
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mathieupauly</groupId>
<artifactId>xxx</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@thieux
thieux / 101-refactoring-java.md
Last active October 9, 2018 21:32
Simplified refactoring

Refactoring from real life

Nested duplicate

Response foo(a.Error error) {
  if (error == a.OK) {
    response = new Response()
    process(response)
    response.setId(id)
@thieux
thieux / BoitePetri.java
Created September 25, 2018 10:02
Jeu de la vie
for (BoitePetri boite = new BoitePetri(16); boite.generation() < 100; boite = boite.prochaineGeneration()) {
System.out.println(boite);
}
function isValidMove(turn, piece, startSquare, endSquare) {
const startFile = startSquare[0];
const endFile = endSquare[0];
const startRank = startSquare[1];
const endRank = endSquare[1];
if (endRank - startRank > 1) {
return false;
}
@thieux
thieux / update-join-postgre.sql
Created August 16, 2018 21:54
Sample of an inline update from a reconciliation query on PostgreSQL 10
create table bar (id int, top int, extid varchar)
insert into bar values
(1, 0, 'MC1234'),
(2, 1, 'FR1234'),
(3, 1, 'MC9876'),
(4, 0, 'MC5678')
commit
@thieux
thieux / JeuDeLaVieIhm.java
Created March 13, 2018 14:19
Jeu de la vie en Swing à compléter
package com.mathieupauly.jeudelavie;
import javax.swing.*;
import java.awt.*;
import java.util.Arrays;
public class JeuDeLaVieIhm extends JFrame {
private static final int TAILLE_PLATEAU = 3;
private static final float TAILLE_POLICE = 50f;
@thieux
thieux / RegexTest.java
Created January 31, 2018 00:51
Java style regular expressions kata in Java
package com.mathieupauly.regexkata;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class RegexTest {
@Test
public void selfMatching() {
assertThat("a".matches("a")).isEqualTo(true);