Commit b786f270 authored by Khalid Ali's avatar Khalid Ali
Browse files

Remove unused Beer package.

parent b425af1f
......@@ -14,6 +14,10 @@ plugins {
id "org.flywaydb.flyway" version "5.2.4"
}
plugins {
id "org.sonarqube" version "2.6"
}
flyway {
url= "jdbc:postgresql://localhost:26257/testdb"
user= "user17"
......
package com.gmu.bookshare.beer;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Data
@NoArgsConstructor
@Entity
class Beer {
public Beer(String name) {
this.name = name;
}
@Id
@GeneratedValue
private Long id;
@NonNull
private String name;
}
\ No newline at end of file
package com.gmu.bookshare.beer;
import org.springframework.stereotype.Component;
@Component
public class BeerCommandLineRunner {//implements CommandLineRunner {
// private final BeerRepository repository;
//
// public BeerCommandLineRunner(BeerRepository repository) {
// this.repository = repository;
// }
//
// @Override
// public void run(String... strings) throws Exception {
// // Top beers from https://www.beeradvocate.com/lists/us, November 2018
// Stream.of("Kentucky Brunch Brand Stout", "Marshmallow Handjee", "Barrel-Aged Abraxas",
// "Hunahpu's Imperial Stout", "King Julius", "Heady Topper",
// "Budweiser", "Coors Light", "PBR").forEach(name ->
// repository.save(new Beer(name))
// );
// repository.findAll().forEach(System.out::println);
// }
}
\ No newline at end of file
package com.gmu.bookshare.beer;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.stream.Collectors;
@RestController
public class BeerController {
private BeerRepository repository;
public BeerController(BeerRepository repository) {
this.repository = repository;
}
@GetMapping("/good-beers")
@CrossOrigin(origins = "http://localhost:8081")
public Collection<Beer> goodBeers() {
return repository.findAll().stream()
.filter(this::isGreat)
.collect(Collectors.toList());
}
private boolean isGreat(Beer beer) {
return !beer.getName().equals("Budweiser") &&
!beer.getName().equals("Coors Light") &&
!beer.getName().equals("PBR");
}
}
\ No newline at end of file
package com.gmu.bookshare.beer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource
interface BeerRepository extends JpaRepository<Beer, Long> {
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment