Skip to content

Instantly share code, notes, and snippets.

View Gueka's full-sized avatar
🎯
Focusing

Marco Gueka

🎯
Focusing
View GitHub Profile
@Gueka
Gueka / http-ping.py
Last active December 19, 2019 19:25
python3 http-ping.py http://test.com.ar
#! /usr/bin/python3
import pip._vendor.requests as requests
import sys
import time
import socket
import re
# TODO add a validation param
url = sys.argv[1]
counter = 0
@Gueka
Gueka / WeatherServiceTest.java
Created August 14, 2019 04:00
How to configure mockito with spring boot for test
package net.gueka.tutorials.weatherapi.service;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
@Gueka
Gueka / WeatherService.java
Created August 14, 2019 02:18
How to configure a service using spring cache abstraction
package net.gueka.tutorials.weatherapi.service;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.ResponseEntity;
@Gueka
Gueka / WeatherService.java
Last active August 14, 2019 03:41
How to configure a service using spring cache abstraction
@Slf4j
@Service
@CacheConfig(cacheNames={"weather"})
public class WeatherService {
public static final String WEATHER_API_URL = "https://api.openweathermap.org/data/2.5/weather?zip=%s,%s&appid=%s&units=metric";
@Value("${weather.appid}")
String appid;
@Gueka
Gueka / schema.xsd
Created August 9, 2019 16:40
Example of a xsd file
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.gueka.net/promo/schema"
targetNamespace="http://www.gueka.net/promo/schema" elementFormDefault="qualified">
<xs:element name="promotionRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="tns:data"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@Gueka
Gueka / gradle.build
Created August 9, 2019 16:39
Gradle example to create a SOAP web service with spring boot
buildscript {
ext {
jaxbVersion = '2.3.2'
wsdlVersion = '1.6.3'
junitVersion = '5.3.2'
}
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
@Gueka
Gueka / WebServiceConfig.java
Last active August 9, 2019 16:38
Example of a soap service configuration
package net.gueka.promo.config;
import javax.servlet.Servlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
@Gueka
Gueka / IntegrationTest.java
Created August 1, 2019 17:37
An integration test example for Spring boot with Cassandra embedded database
package net.gueka.user;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@Gueka
Gueka / UserRepository.java
Created August 1, 2019 17:36
An Spring boot Cassandra repository example
package net.gueka.user.repository;
import java.util.UUID;
import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;
import net.gueka.user.model.User;
@Repository
@Gueka
Gueka / User.java
Created August 1, 2019 17:35
Cassandra model for spring boot using lombok
package net.gueka.user.model;
import java.util.List;
import java.util.UUID;
import com.datastax.driver.core.DataType.Name;
import org.springframework.data.cassandra.core.mapping.CassandraType;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;