Skip to content

Instantly share code, notes, and snippets.

View shinyay's full-sized avatar

Shinya Yanagihara shinyay

View GitHub Profile
        val result = mockMvc.perform(get("/api/v1/books/978-4-7710-1067-3"))
            .andDo(MockMvcResultHandlers.print())
            .andExpect(status().isOk)
            .andReturn()
        val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, Book::class.java)
        val bookObject: List<Book> = objectMapper.readValue(result.response.contentAsString, javaType)
        assertThat(bookObject[0].price).isEqualTo(100)

Boot Spring Cloud GCP

Spring Cloud GCP with Cloud SQL

$ ./gradlew clean bootRun --args=""--spring.cloud.gcp.sql.instance-connection-name=(gcloud sql instances describe my-mysql --format='value(connectionName)')""
@shinyay
shinyay / gitignore.md
Created September 6, 2021 07:00
.gitignore for Gradle and Maven

.gitignore for Gradle and Maven

HELP.md

### Gradle ###
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
@shinyay
shinyay / 1-bestoractuces-java-container.md
Last active October 3, 2025 15:48
Dockerfile Best Practice

Best Practices to build Java Container

  1. Use explicit and deterministic Docker base image tags
  2. Install only what you need in production in the Java container image
  3. Find and fix security vulnerabilities in your Java Docker image
  4. Use multi-stage builds
  5. Don’t run Java apps as root
  6. Properly handle events to safely terminate a Java application
  7. Gracefully tear down Java applications
  8. Use .dockerignore
@shinyay
shinyay / spring-profile.md
Created June 14, 2021 14:15
Run Spring Boot app with Profile

Run Spring Boot app with Profile

Profile

app.name=sample
app.name.profile=default
#---
spring.config.activate.on-profile=dev
app.name.profile=dev
#---

@ConfigurationProperties

src/main/resources/application.properties

app.config.app-name=Sample

src/main/java/*/properties/AppConfigProperties.java

@Getter

Project by Gradle Init

$ gradle init -p simple-app --type java-application --dsl groovy --test-framework junit-jupiter --project-name simple-app --package simple.app
@shinyay
shinyay / envsubst-template.md
Created May 31, 2021 09:14
Simple template by envsubst

envsubst Template

Template

$ echo 'pwd=${PWD}' > sample.tpl

Convert with Environment Variables

$ envsubst &lt; sample.tpl &gt; sample.txt
@shinyay
shinyay / maven-surefire-report.md
Last active May 28, 2021 01:56
Surefire Report by Maven

Surefire Report

$ ./mvnw clean \
    test -Dmaven.test.failure.ignore=true \
    site -DgenerateReports=false \
    surefire-report:report

Surefire Report