mercredi 21 août 2019

JSON Schema : How to specify that a string property contains base64-encoded PNG images

By adding : The contentMediaType and contentEncoding

Example

Here is an example schema, illustrating the use of "contentEncoding" and "contentMediaType":
{
    "type": "string",
    "contentEncoding": "base64",
    "contentMediaType": "image/png"
}

                    
Instances described by this schema should be strings, and their values should be interpretable as base64-encoded PNG images.
Another example:
{
    "type": "string",
    "contentMediaType": "text/html"
}

                    

Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode)

 contentEncoding

If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property. RFC 2045, Sec 6.1 [RFC2045]lists the possible values for this property.

The value of this property MUST be a string.

contentMediaType

The value of this property must be a media type, as defined by RFC 2046 [RFC2046]. This property defines the media type of instances which this schema defines.
The value of this property MUST be a string.
The value of this property SHOULD be ignored if the instance described is not a string.
If the "contentEncoding" property is not present, but the instance value is a string, then the value of this property SHOULD specify a text document type, and the character set SHOULD be the character set into which the JSON string value was decoded (for which the default is Unicode).

lundi 19 août 2019

Git : How test pushing the feature/feature1 branch to a remote origin?


Il faut utiliser l'option --dry-run de push, pour voir si vous avez les droits!


git push --dry-run origin feature/feature1


Git : When to Use Git Reset, Git Revert & Git Checkout

Mockito : « Stubbing » pré-programmés l'objet avec les attentes du système à tester.

Le stubbing permet de définir le comportement des objets mockés face aux appels de méthodes sur ces objets.

Plusieurs méthodes de stubbing sont possibles :
  1. Retour d’une valeur unique
Mockito.when(user.getLogin()).thenReturn(‘user1’); //la chaine de caractères user1 sera renvoyée quand la méthode getLogin() sera appelée.
  1. Faire appel à la méthode d’origine
Mockito.when(user.getLogin()).thenCallRealMethod();
  1. Levée d’exceptions
Mockito.when(user.getLogin()).thenThrow(new RuntimeException());
Il faut noter que la méthode retournera toujours la valeur stubbée, peu importe combien de fois elle est appelée . Si on stubb la même méthode ayant la même signature plusieurs fois, le dernier stubbing sera pris en compte.
Mockito.when(user.getLogin()).ThenThrow(new RuntimeException()).ThenReturn(« foo »);
Ici le premier appel va lever une exception, tous les appels qui suivront retourneront « foo ».
  1. Retours de valeurs consécutives
Mockito.when(user.getLogin()).thenReturn(‘user1’,’user2’,’user3’);
Le premier appel retourne user1, le deuxième retournera user2 le troisième user3. Tous les appels qui suivent retourneront la dernière valeur c’est à dire user3.
  1. Ne rien retourner
 Mockito.doNothing().when(user.getLogin());

lundi 5 août 2019

How A typical Jenkins build works? Comment fonctionne un build type avec Jenkins?


Le développeur modifie le code: le développeur commit le nouveau code dans le gestionnaire

de version (généralement Git ou Subversion) et le fait un push au répo central.
Le code est transmis au serveur de build: Jenkins surveille le répo en permanence.

Lorsqu'il voit un nouveau commit, il vérifie que la  version du code compile
Le build de l'application: à l'aide de scripts de build également commiter pour le répo,
Jenkins construit (build) le logiciel.
Exécutez les tests automatisés: des tests unitaires et / ou des tests d'intégration sont

également gérés par l'équipe de développement dans le cadre du projet.
Jenkins utilise un script de test pour exécuter ces tests.
Notifier les développeurs des problèmes: Jenkins maintient une liste de résultats des

builds que les développeurs peuvent facilement visualiser à l'aide de son interface Web.
Jenkins peut également être configuré pour envoyer des emails aux développeurs en cas d'échec du build.