Test

Se han creado los test unitarios y los test de integración de la aplicación realizada
parent 4dfb13fc
drop database if exists `daaexample`;
CREATE DATABASE `daaexample`;
CREATE TABLE `daaexample`.`people` (
......@@ -14,7 +15,16 @@ CREATE TABLE `daaexample`.`users` (
PRIMARY KEY (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE USER 'daa'@'localhost' IDENTIFIED WITH mysql_native_password BY 'daa';
CREATE TABLE `daaexample`.`pets` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`kind` varchar(100) NOT NULL,
`owner` int(100) NOT NULL,
FOREIGN KEY (`owner`) REFERENCES `daaexample`.`people`(`id`) ON DELETE CASCADE,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE USER if not exists 'daa'@'localhost' IDENTIFIED WITH mysql_native_password BY 'daa';
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost';
INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Antón','Pérez');
......@@ -26,6 +36,9 @@ INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'María','Nu
INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Alba','Fernández');
INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Asunción','Jiménez');
INSERT INTO `daaexample`.`pets` (`id`,`name`,`kind`, `id_owner`) VALUES (0,'LAIKA','PERRO',1);
INSERT INTO `daaexample`.`pets` (`id`,`name`,`kind`, `id_owner`) VALUES (0,'ALASKA','GATO',1);
-- The password for each user is its login suffixed with "pass". For example, user "admin" has the password "adminpass".
INSERT INTO `daaexample`.`users` (`login`,`password`,`role`)
VALUES ('admin', '713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca','ADMIN');
......
......@@ -5,14 +5,13 @@ CREATE TABLE `daaexample`.`people` (
`name` varchar(50) NOT NULL,
`surname` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `daaexample`.`users` (
`login` varchar(100) NOT NULL,
`password` varchar(64) NOT NULL,
`role` varchar(10) NOT NULL,
PRIMARY KEY (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE USER 'daa'@'localhost' IDENTIFIED WITH mysql_native_password BY 'daa';
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost';
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost' IDENTIFIED BY 'daa';
......@@ -23,6 +23,36 @@ import es.uvigo.esei.daa.entities.Pet;
public class PetsDAO extends DAO {
private final static Logger LOG = Logger.getLogger(PetsDAO.class.getName());
/**
* Returns a pepetrson stored persisted in the system.
*
* @param id identifier of the pet.
* @return a pet with the provided identifier.
* @throws DAOException if an error happens while retrieving the pet.
* @throws IllegalArgumentException if the provided id does not corresponds
* with any persisted pet.
*/
public Pet get(int id)
throws DAOException, IllegalArgumentException {
try (final Connection conn = this.getConnection()) {
final String query = "SELECT * FROM pets WHERE id=?";
try (final PreparedStatement statement = conn.prepareStatement(query)) {
statement.setInt(1, id);
try (final ResultSet result = statement.executeQuery()) {
if (result.next()) {
return rowToEntity(result);
} else {
throw new IllegalArgumentException("Invalid id");
}
}
}
} catch (SQLException e) {
LOG.log(Level.SEVERE, "Error getting a pet", e);
throw new DAOException(e);
}
}
/**
* Returns a list with all the pets persisted in the system.
......@@ -52,6 +82,33 @@ public class PetsDAO extends DAO {
}
}
/**
* Returns a list with all the people persisted in the system.
*
* @return a list with all the people persisted in the system.
* @throws DAOException if an error happens while retrieving the people.
*/
public List<Pet> list() throws DAOException {
try (final Connection conn = this.getConnection()) {
final String query = "SELECT * FROM pets";
try (final PreparedStatement statement = conn.prepareStatement(query)) {
try (final ResultSet result = statement.executeQuery()) {
final List<Pet> pets = new LinkedList<>();
while (result.next()) {
pets.add(rowToEntity(result));
}
return pets;
}
}
} catch (SQLException e) {
LOG.log(Level.SEVERE, "Error listing pets", e);
throw new DAOException(e);
}
}
/**
* Removes a persisted pet from the system.
*
......
......@@ -27,7 +27,7 @@ public class Pet {
this.id = id;
this.setName(name);
this.setKind(kind);
this.setOwner(owner);
this.owner = owner;
}
/**
......@@ -87,16 +87,6 @@ public class Pet {
return owner;
}
/**
* Set the id of this owner.
*
* @param owner the new id of the owner.
* @throws NullPointerException if the {@code surname} is {@code null}.
*/
public void setOwner(int owner) {
this.owner = requireNonNull(owner, "The owner' id can't be null");
}
@Override
public int hashCode() {
final int prime = 31;
......@@ -118,4 +108,7 @@ public class Pet {
return false;
return true;
}
}
......@@ -43,6 +43,40 @@ public class PetsResource {
this.dao = dao;
}
/**
* Returns a pet with the provided identifier.
*
* @param id the identifier of the pet to retrieve.
* @return a 200 OK response with a pet that has the provided identifier.
* If the identifier does not corresponds with any user, a 400 Bad Request
* response with an error message will be returned. If an error happens
* while retrieving the list, a 500 Internal Server Error response with an
* error message will be returned.
*/
@GET
@Path("/{id}")
public Response get(
@PathParam("id") int id
) {
try {
final Pet pet = this.dao.get(id);
return Response.ok(pet).build();
} catch (IllegalArgumentException iae) {
LOG.log(Level.FINE, "Invalid pet id in get method", iae);
return Response.status(Response.Status.BAD_REQUEST)
.entity(iae.getMessage())
.build();
} catch (DAOException e) {
LOG.log(Level.SEVERE, "Error getting a pet", e);
return Response.serverError()
.entity(e.getMessage())
.build();
}
}
/**
* Returns the complete list of pets stored in the system.
*
......@@ -52,11 +86,16 @@ public class PetsResource {
*/
@GET
public Response list(
@QueryParam("owner") int id
@QueryParam("owner") Integer id
) {
try {
if(id == null){
return Response.ok(this.dao.list()).build();
}else{
return Response.ok(this.dao.list(id)).build();
}
} catch (DAOException e) {
LOG.log(Level.SEVERE, "Error listing pets", e);
return Response.serverError().entity(e.getMessage()).build();
......
package es.uvigo.esei.daa.dao;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentId;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.newName;
import static es.uvigo.esei.daa.dataset.PetsDataset.newPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.newKind;
import static es.uvigo.esei.daa.dataset.PetsDataset.newOwner;
import static es.uvigo.esei.daa.dataset.PetsDataset.pets;
import static es.uvigo.esei.daa.dataset.PetsDataset.nonExistentId;
import static es.uvigo.esei.daa.dataset.PetsDataset.nonExistentPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.petsWithout;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.containsPetsInAnyOrder;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.equalsToPet;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import javax.sql.DataSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.github.springtestdbunit.DbUnitTestExecutionListener;
import com.github.springtestdbunit.annotation.DatabaseSetup;
import com.github.springtestdbunit.annotation.ExpectedDatabase;
import es.uvigo.esei.daa.entities.Pet;
import es.uvigo.esei.daa.listeners.ApplicationContextBinding;
import es.uvigo.esei.daa.listeners.ApplicationContextJndiBindingTestExecutionListener;
import es.uvigo.esei.daa.listeners.DbManagement;
import es.uvigo.esei.daa.listeners.DbManagementTestExecutionListener;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:contexts/mem-context.xml")
@TestExecutionListeners({
DbUnitTestExecutionListener.class,
DbManagementTestExecutionListener.class,
ApplicationContextJndiBindingTestExecutionListener.class
})
@ApplicationContextBinding(
jndiUrl = "java:/comp/env/jdbc/daaexample",
type = DataSource.class
)
@DbManagement(
create = "classpath:db/hsqldb.sql",
drop = "classpath:db/hsqldb-drop.sql"
)
@DatabaseSetup("/datasets/dataset.xml")
@ExpectedDatabase("/datasets/dataset.xml")
public class PetsDAOTest {
private PetsDAO dao;
@Before
public void setUp() throws Exception {
this.dao = new PetsDAO();
}
@Test
public void testList() throws DAOException {
assertThat(this.dao.list(newOwner()), containsPetsInAnyOrder(pets()));
}
@Test
public void testGet() throws DAOException {
final Pet pet = this.dao.get(existentId());
assertThat(pet, is(equalsToPet(existentPet())));
}
@Test(expected = IllegalArgumentException.class)
public void testGetNonExistentId() throws DAOException {
this.dao.get(nonExistentId());
}
@Test
@ExpectedDatabase("/datasets/dataset-delete-pets.xml")
public void testDelete() throws DAOException {
this.dao.delete(existentId());
assertThat(this.dao.list(newOwner()), containsPetsInAnyOrder(petsWithout(existentId())));
}
@Test(expected = IllegalArgumentException.class)
public void testDeleteNonExistentId() throws DAOException {
this.dao.delete(nonExistentId());
}
@Test
@ExpectedDatabase("/datasets/dataset-modify-pets.xml")
public void testModify() throws DAOException {
final Pet pet = existentPet();
pet.setName(newName());
pet.setKind(newKind());
this.dao.modify(pet);
final Pet persistentPet = this.dao.get(pet.getId());
assertThat(persistentPet, is(equalsToPet(pet)));
}
@Test(expected = IllegalArgumentException.class)
public void testModifyNonExistentId() throws DAOException {
this.dao.modify(nonExistentPet());
}
@Test(expected = IllegalArgumentException.class)
public void testModifyNullPet() throws DAOException {
this.dao.modify(null);
}
@Test
@ExpectedDatabase("/datasets/dataset-add-pets.xml")
public void testAdd() throws DAOException {
final Pet pet = this.dao.add(newName(), newKind(), Integer.toString(newOwner()));
assertThat(pet, is(equalsToPet(newPet())));
final Pet persistentPet = this.dao.get(pet.getId());
assertThat(persistentPet, is(equalsToPet(newPet())));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullName() throws DAOException {
this.dao.add(null, newKind(), Integer.toString(newOwner()));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullSurname() throws DAOException {
this.dao.add(newName(), null, Integer.toString(newOwner()));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullOwner() throws DAOException {
this.dao.add(newName(), newKind(), null);
}
}
package es.uvigo.esei.daa.dao;
import static es.uvigo.esei.daa.dataset.PetsDataset.pets;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentId;
import static es.uvigo.esei.daa.dataset.PetsDataset.newName;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.newKind;
import static es.uvigo.esei.daa.dataset.PetsDataset.newOwner;
import static es.uvigo.esei.daa.dataset.PetsDataset.newPet;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.equalsToPet;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.containsPetsInAnyOrder;
import static org.easymock.EasyMock.anyString;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.reset;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import java.sql.SQLException;
import org.junit.Test;
import com.mysql.jdbc.Statement;
import es.uvigo.esei.daa.entities.Pet;
import es.uvigo.esei.daa.util.DatabaseQueryUnitTest;
public class PetsDAOUnitTest extends DatabaseQueryUnitTest{
@Test
public void testList() throws Exception {
final Pet[] pets = pets();
for (Pet pet : pets) {
expectPetRow(pet);
}
expect(result.next()).andReturn(false);
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
assertThat(petsDAO.list(newOwner()), containsPetsInAnyOrder(pets));
}
@Test(expected = DAOException.class)
public void testListUnexpectedException() throws Exception {
expect(result.next()).andThrow(new SQLException());
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.list(newOwner());
}
@Test
public void testGet() throws Exception {
final Pet existentPet = existentPet();
expectPetRow(existentPet);
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
assertThat(petsDAO.get(existentId()), is(equalTo(existentPet)));
}
@Test(expected = IllegalArgumentException.class)
public void testGetMissing() throws Exception {
expect(result.next()).andReturn(false);
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.get(existentId());
}
@Test(expected = DAOException.class)
public void testGetUnexpectedException() throws Exception {
expect(result.next()).andThrow(new SQLException());
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.get(existentId());
}
@Test
public void testAdd() throws Exception {
final Pet pet = newPet();
reset(connection);
expect(connection.prepareStatement(anyString(), eq(Statement.RETURN_GENERATED_KEYS)))
.andReturn(statement);
expect(statement.executeUpdate()).andReturn(1);
expect(statement.getGeneratedKeys()).andReturn(result);
// Key retrieval
expect(result.next()).andReturn(true);
expect(result.getInt(1)).andReturn(pet.getId());
connection.close();
result.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
final Pet newPet = petsDAO.add(pet.getName(), pet.getKind(), Integer.toString(pet.getOwner()));
assertThat(newPet, is(equalsToPet(pet)));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullName() throws Exception {
replayAll();
final PetsDAO petsDAO = new PetsDAO();
resetAll(); // No expectations
petsDAO.add(null, newKind(), Integer.toString(newOwner()));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullKind() throws Exception {
replayAll();
final PetsDAO petsDAO = new PetsDAO();
resetAll(); // No expectations
petsDAO.add(newName(), null, Integer.toString(newOwner()));
}
@Test(expected = IllegalArgumentException.class)
public void testAddNullOwner() throws Exception {
replayAll();
final PetsDAO petsDAO = new PetsDAO();
resetAll(); // No expectations
petsDAO.add(newName(), newKind(), null);
}
@Test(expected = DAOException.class)
public void testAddZeroUpdatedRows() throws Exception {
reset(connection);
expect(connection.prepareStatement(anyString(), eq(1)))
.andReturn(statement);
expect(statement.executeUpdate()).andReturn(0);
connection.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.add(newName(), newKind(),Integer.toString(newOwner()));
}
@Test(expected = DAOException.class)
public void testAddNoGeneratedKey() throws Exception {
reset(connection);
expect(connection.prepareStatement(anyString(), eq(1)))
.andReturn(statement);
expect(statement.executeUpdate()).andReturn(1);
expect(statement.getGeneratedKeys()).andReturn(result);
expect(result.next()).andReturn(false);
result.close();
connection.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.add(newName(), newKind(), Integer.toString(newOwner()));
}
@Test(expected = DAOException.class)
public void testAddUnexpectedException() throws Exception {
reset(connection);
expect(connection.prepareStatement(anyString(), eq(1)))
.andReturn(statement);
expect(statement.executeUpdate()).andThrow(new SQLException());
connection.close();
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.add(newName(), newKind(), Integer.toString(newOwner()));
}
@Test
public void testDelete() throws Exception {
expect(statement.executeUpdate()).andReturn(1);
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.delete(newOwner());
}
@Test(expected = IllegalArgumentException.class)
public void testDeleteInvalidId() throws Exception {
expect(statement.executeUpdate()).andReturn(0);
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.delete(newOwner());
}
@Test(expected = DAOException.class)
public void testDeleteUnexpectedException() throws Exception {
expect(statement.executeUpdate()).andThrow(new SQLException());
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.delete(newOwner());
}
@Test
public void testModify() throws Exception {
expect(statement.executeUpdate()).andReturn(1);
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.modify(existentPet());
}
@Test(expected = IllegalArgumentException.class)
public void testModifyNullPet() throws Exception {
replayAll();
final PetsDAO petsDAO = new PetsDAO();
resetAll(); // No expectations
petsDAO.modify(null);
}
@Test(expected = IllegalArgumentException.class)
public void testModifyZeroUpdatedRows() throws Exception {
expect(statement.executeUpdate()).andReturn(0);
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.modify(existentPet());
}
@Test(expected = DAOException.class)
public void testModifyUnexpectedException() throws Exception {
expect(statement.executeUpdate()).andThrow(new SQLException());
replayAll();
final PetsDAO petsDAO = new PetsDAO();
petsDAO.modify(existentPet());
}
private void expectPetRow(Pet pet) throws SQLException {
expect(result.next()).andReturn(true);
expect(result.getInt("id")).andReturn(pet.getId());
expect(result.getString("name")).andReturn(pet.getName());
expect(result.getString("kind")).andReturn(pet.getKind());
expect(result.getInt("owner")).andReturn(pet.getOwner());
}
}
package es.uvigo.esei.daa.dataset;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.stream;
import java.util.Arrays;
import java.util.function.Predicate;
import es.uvigo.esei.daa.entities.Pet;
public class PetsDataset {
private PetsDataset() {}
public static Pet[] pets() {
return new Pet[] {
new Pet(1,"Laika", "Perro", 1),
new Pet(2,"Alaska", "Gato", 1),
new Pet(3,"Lucky", "Perro", 1),
new Pet(4,"Luck", "Gato", 1),
new Pet(5,"Pancho", "Perro", 1),
new Pet(6,"Chikita", "Gato", 1),
new Pet(7,"Bethoven", "Perro", 1),
new Pet(8,"Bella", "Perro", 1),
new Pet(9,"Puppi", "Gato", 1),
new Pet(10,"Piolin", "Perro", 1),
};
}
public static Pet[] petsWithout(int ... ids) {
Arrays.sort(ids);
final Predicate<Pet> hasValidId = pet ->
binarySearch(ids, pet.getId()) < 0;
return stream(pets())
.filter(hasValidId)
.toArray(Pet[]::new);
}
public static Pet pet(int id) {
return stream(pets())
.filter(pet -> pet.getId() == id)
.findAny()
.orElseThrow(IllegalArgumentException::new);
}
public static int existentId() {
return 5;
}
public static int nonExistentId() {
return 1234;
}
public static Pet existentPet() {
return pet(existentId());
}
public static Pet nonExistentPet() {
return new Pet(nonExistentId(), "Silvestre", "Perro", 1);
}
public static String newName() {
return "Sultán";
}
public static String newKind() {
return "Gato";
}
public static int newOwner() {
return 1;
}
public static Pet newPet() {
return new Pet(pets().length + 1, newName(), newKind(), newOwner());
}
}
package es.uvigo.esei.daa.entities;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
public class PetUnitTest {
@Test
public void testPetIntStringStringInt() {
final int id = 1;
final String name = "Laika";
final String kind = "Perro";
final int owner = 1;
final Pet pet = new Pet(id, name, kind, owner);
assertThat(pet.getId(), is(equalTo(id)));
assertThat(pet.getName(), is(equalTo(name)));
assertThat(pet.getKind(), is(equalTo(kind)));
assertThat(pet.getOwner(), is(equalTo(owner)));
}
@Test(expected = NullPointerException.class)
public void testPetIntStringStringIntNullName() {
new Pet(1, null, "Perro", 1);
}
@Test(expected = NullPointerException.class)
public void testPetIntStringStringIntNullKind() {
new Pet(1, "Laika", null, 1);
}
@Test(expected = NullPointerException.class)
public void testPetIntStringStringIntNullOwner() {
Integer owner = null;
new Pet(1, "Laika", "Perro", owner);
}
@Test
public void testSetName() {
final int id = 1;
final String kind = "Perro";
final int owner = 1;
final Pet pet = new Pet(id, "Laika", kind,owner);
pet.setName("Alaska");
assertThat(pet.getId(), is(equalTo(id)));
assertThat(pet.getName(), is(equalTo("Alaska")));
assertThat(pet.getKind(), is(equalTo(kind)));
assertThat(pet.getOwner(), is(equalTo(owner)));
}
@Test(expected = NullPointerException.class)
public void testSetNullName() {
final Pet pet = new Pet(1, "Laika", "Perro", 1);
pet.setName(null);
}
@Test
public void testSetKind() {
final int id = 1;
final String name = "Laika";
final int owner = 1;
final Pet pet = new Pet(id, name, "Perro", owner);
pet.setKind("Gato");
assertThat(pet.getId(), is(equalTo(id)));
assertThat(pet.getName(), is(equalTo(name)));
assertThat(pet.getKind(), is(equalTo("Gato")));
assertThat(pet.getOwner(), is(equalTo(owner)));
}
@Test(expected = NullPointerException.class)
public void testSetNullKind() {
final Pet pet = new Pet(1, "Laika", "Perro", 1);
pet.setKind(null);
}
@Test
public void testEqualsObject() {
final Pet petA = new Pet(1, "Name A", "Surname A", 1);
final Pet petB = new Pet(1, "Name B", "Surname B", 1);
assertTrue(petA.equals(petB));
}
@Test
public void testEqualsHashcode() {
EqualsVerifier.forClass(Pet.class)
.withIgnoredFields("name", "kind", "owner")
.suppress(Warning.STRICT_INHERITANCE)
.suppress(Warning.NONFINAL_FIELDS)
.verify();
}
}
......@@ -57,8 +57,12 @@ public class AuthorizationFilter implements ContainerRequestFilter {
if (isPeoplePath(requestContext) && !user.getRole().equals("ADMIN")) {
requestContext.abortWith(createResponse());
} else {
if (isPetsPath(requestContext) && !user.getRole().equals("ADMIN")) {
requestContext.abortWith(createResponse());
}else{
requestContext.setSecurityContext(new UserSecurityContext(user));
}
}
} else {
requestContext.abortWith(createResponse());
}
......@@ -76,6 +80,11 @@ public class AuthorizationFilter implements ContainerRequestFilter {
return !pathSegments.isEmpty() && pathSegments.get(0).getPath().equals("people");
}
private static boolean isPetsPath(ContainerRequestContext context) {
final List<PathSegment> pathSegments = context.getUriInfo().getPathSegments();
return !pathSegments.isEmpty() && pathSegments.get(0).getPath().equals("pets");
}
private static Response createResponse() {
return Response.status(Status.UNAUTHORIZED)
.header(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"DAAExample\"")
......
package es.uvigo.esei.daa.matchers;
import static org.junit.Assert.*;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import es.uvigo.esei.daa.entities.Pet;
public class IsEqualToPet extends IsEqualToEntity<Pet> {
public IsEqualToPet(Pet entity) {
super(entity);
}
@Override
protected boolean matchesSafely(Pet actual) {
this.clearDescribeTo();
if (actual == null) {
this.addTemplatedDescription("actual", expected.toString());
return false;
} else {
return checkAttribute("id", Pet::getId, actual)
&& checkAttribute("name", Pet::getName, actual)
&& checkAttribute("kind", Pet::getKind, actual)
&& checkAttribute("owner", Pet::getOwner, actual);
}
}
/**
* Factory method that creates a new {@link IsEqualToEntity} matcher with
* the provided {@link Pet} as the expected value.
*
* @param pet the expected pet.
* @return a new {@link IsEqualToEntity} matcher with the provided
* {@link Pet} as the expected value.
*/
@Factory
public static IsEqualToPet equalsToPet(Pet pet) {
return new IsEqualToPet(pet);
}
/**
* Factory method that returns a new {@link Matcher} that includes several
* {@link IsEqualToPet} matchers, each one using an {@link Pet} of the
* provided ones as the expected value.
*
* @param pets the pets to be used as the expected values.
* @return a new {@link Matcher} that includes several
* {@link IsEqualToPet} matchers, each one using an {@link Pet} of the
* provided ones as the expected value.
* @see IsEqualToEntity#containsEntityInAnyOrder(java.util.function.Function, Object...)
*/
@Factory
public static Matcher<Iterable<? extends Pet>> containsPetsInAnyOrder(Pet ... pets) {
return containsEntityInAnyOrder(IsEqualToPet::equalsToPet, pets);
}
}
This diff is collapsed.
package es.uvigo.esei.daa.rest;
import static es.uvigo.esei.daa.dataset.PetsDataset.pets;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.existentId;
import static es.uvigo.esei.daa.dataset.PetsDataset.newName;
import static es.uvigo.esei.daa.dataset.PetsDataset.newPet;
import static es.uvigo.esei.daa.dataset.PetsDataset.newKind;
import static es.uvigo.esei.daa.dataset.PetsDataset.newOwner;
import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasBadRequestStatus;
import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasInternalServerErrorStatus;
import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasOkStatus;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.equalsToPet;
import static es.uvigo.esei.daa.matchers.IsEqualToPet.containsPetsInAnyOrder;
import static java.util.Arrays.asList;
import static org.easymock.EasyMock.anyInt;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import java.util.List;
import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import es.uvigo.esei.daa.dao.DAOException;
import es.uvigo.esei.daa.dao.PetsDAO;
import es.uvigo.esei.daa.entities.Pet;
public class PetsResourceUnitTest {
private PetsDAO daoMock;
private PetsResource resource;
@Before
public void setUp() throws Exception {
daoMock = createMock(PetsDAO.class);
resource = new PetsResource(daoMock);
}
@After
public void tearDown() throws Exception {
try {
verify(daoMock);
} finally {
daoMock = null;
resource = null;
}
}
@Test
@SuppressWarnings("unchecked")
public void testList() throws Exception {
final List<Pet> pet = asList(pets());
expect(daoMock.list(newOwner())).andReturn(pet);
replay(daoMock);
final Response response = resource.list(newOwner());
assertThat(response, hasOkStatus());
assertThat((List<Pet>) response.getEntity(), containsPetsInAnyOrder(pets()));
}
@Test
public void testListDAOException() throws Exception {
expect(daoMock.list(newOwner())).andThrow(new DAOException());
replay(daoMock);
final Response response = resource.list(newOwner());
assertThat(response, hasInternalServerErrorStatus());
}
@Test
public void testGet() throws Exception {
final Pet pet = existentPet();
expect(daoMock.get(pet.getId())).andReturn(pet);
replay(daoMock);
final Response response = resource.get(pet.getId());
assertThat(response, hasOkStatus());
assertThat((Pet) response.getEntity(), is(equalsToPet(pet)));
}
@Test
public void testGetDAOException() throws Exception {
expect(daoMock.get(anyInt())).andThrow(new DAOException());
replay(daoMock);
final Response response = resource.get(existentId());
assertThat(response, hasInternalServerErrorStatus());
}
@Test
public void testGetIllegalArgumentException() throws Exception {
expect(daoMock.get(anyInt())).andThrow(new IllegalArgumentException());
replay(daoMock);
final Response response = resource.get(existentId());
assertThat(response, hasBadRequestStatus());
}
@Test
public void testDelete() throws Exception {
daoMock.delete(anyInt());
replay(daoMock);
final Response response = resource.delete(1);
assertThat(response, hasOkStatus());
}
@Test
public void testDeleteDAOException() throws Exception {
daoMock.delete(anyInt());
expectLastCall().andThrow(new DAOException());
replay(daoMock);
final Response response = resource.delete(1);
assertThat(response, hasInternalServerErrorStatus());
}
@Test
public void testDeleteIllegalArgumentException() throws Exception {
daoMock.delete(anyInt());
expectLastCall().andThrow(new IllegalArgumentException());
replay(daoMock);
final Response response = resource.delete(1);
assertThat(response, hasBadRequestStatus());
}
@Test
public void testModify() throws Exception {
final Pet pet = existentPet();
pet.setName(newName());
pet.setKind(newKind());
daoMock.modify(pet);
replay(daoMock);
final Response response = resource.modify(
pet.getId(), pet.getName(), pet.getKind(),Integer.toString(pet.getOwner()));
assertThat(response, hasOkStatus());
assertEquals(pet, response.getEntity());
}
@Test
public void testModifyDAOException() throws Exception {
daoMock.modify(anyObject());
expectLastCall().andThrow(new DAOException());
replay(daoMock);
final Response response = resource.modify(existentId(), newName(), newKind(), Integer.toString(newOwner()));
assertThat(response, hasInternalServerErrorStatus());
}
@Test
public void testModifyIllegalArgumentException() throws Exception {
daoMock.modify(anyObject());
expectLastCall().andThrow(new IllegalArgumentException());
replay(daoMock);
final Response response = resource.modify(existentId(), newName(), newKind(), Integer.toString(newOwner()));
assertThat(response, hasBadRequestStatus());
}
@Test
public void testModifyNullPointerException() throws Exception {
daoMock.modify(anyObject());
expectLastCall().andThrow(new NullPointerException());
replay(daoMock);
final Response response = resource.modify(existentId(), newName(), newKind(), Integer.toString(newOwner()));
assertThat(response, hasBadRequestStatus());
}
@Test
public void testAdd() throws Exception {
expect(daoMock.add(newName(), newKind(),Integer.toString(newOwner())))
.andReturn(newPet());
replay(daoMock);
final Response response = resource.add(newName(), newKind(), Integer.toString(newOwner()));
assertThat(response, hasOkStatus());
assertThat((Pet) response.getEntity(), is(equalsToPet(newPet())));
}
@Test
public void testAddDAOException() throws Exception {
expect(daoMock.add(anyString(), anyString(),Integer.toString(anyInt())))
.andThrow(new DAOException());
replay(daoMock);
final Response response = resource.add(newName(), newKind(),Integer.toString(newOwner()));
assertThat(response, hasInternalServerErrorStatus());
}
@Test
public void testAddIllegalArgumentException() throws Exception {
expect(daoMock.add(anyString(), anyString(),Integer.toString(anyInt())))
.andThrow(new IllegalArgumentException());
replay(daoMock);
final Response response = resource.add(newName(), newKind(),Integer.toString(newOwner()));
assertThat(response, hasBadRequestStatus());
}
}
......@@ -6,12 +6,16 @@ import org.junit.runners.Suite.SuiteClasses;
import es.uvigo.esei.daa.dao.PeopleDAOTest;
import es.uvigo.esei.daa.rest.PeopleResourceTest;
import es.uvigo.esei.daa.dao.PetsDAOTest;
import es.uvigo.esei.daa.rest.PetsResourceTest;
import es.uvigo.esei.daa.rest.UsersResourceTest;
@SuiteClasses({
PeopleDAOTest.class,
PeopleResourceTest.class,
UsersResourceTest.class
UsersResourceTest.class,
PetsDAOTest.class,
PetsResourceTest.class
})
@RunWith(Suite.class)
public class IntegrationTestSuite {
......
......@@ -7,11 +7,17 @@ import org.junit.runners.Suite.SuiteClasses;
import es.uvigo.esei.daa.dao.PeopleDAOUnitTest;
import es.uvigo.esei.daa.entities.PersonUnitTest;
import es.uvigo.esei.daa.rest.PeopleResourceUnitTest;
import es.uvigo.esei.daa.dao.PetsDAOUnitTest;
import es.uvigo.esei.daa.entities.PetUnitTest;
import es.uvigo.esei.daa.rest.PetsResourceUnitTest;
@SuiteClasses({
PersonUnitTest.class,
PeopleDAOUnitTest.class,
PeopleResourceUnitTest.class
PeopleResourceUnitTest.class,
PetUnitTest.class,
PetsDAOUnitTest.class,
PetsResourceUnitTest.class
})
@RunWith(Suite.class)
public class UnitTestSuite {
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dataset SYSTEM "dataset.dtd">
<dataset>
<people id="1" name="Antón" surname="Álvarez" />
<people id="2" name="Ana" surname="Amargo" />
<people id="3" name="Manuel" surname="Martínez" />
<people id="4" name="María" surname="Márquez" />
<people id="5" name="Lorenzo" surname="López" />
<people id="6" name="Laura" surname="Laredo" />
<people id="7" name="Perico" surname="Palotes" />
<people id="8" name="Patricia" surname="Pérez" />
<people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" />
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Pancho" kind="Perro" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
<pets id="11" name="Sultán" kind="Gato" owner="1" />
</dataset>
\ No newline at end of file
......@@ -16,4 +16,16 @@
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Pancho" kind="Perro" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
</dataset>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dataset SYSTEM "dataset.dtd">
<dataset>
<people id="1" name="Antón" surname="Álvarez" />
<people id="2" name="Ana" surname="Amargo" />
<people id="3" name="Manuel" surname="Martínez" />
<people id="4" name="María" surname="Márquez" />
<people id="5" name="Lorenzo" surname="López" />
<people id="6" name="Laura" surname="Laredo" />
<people id="7" name="Perico" surname="Palotes" />
<people id="8" name="Patricia" surname="Pérez" />
<people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" />
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
</dataset>
\ No newline at end of file
......@@ -14,4 +14,15 @@
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Pancho" kind="Perro" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
</dataset>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dataset SYSTEM "dataset.dtd">
<dataset>
<people id="1" name="Antón" surname="Álvarez" />
<people id="2" name="Ana" surname="Amargo" />
<people id="3" name="Manuel" surname="Martínez" />
<people id="4" name="María" surname="Márquez" />
<people id="5" name="Lorenzo" surname="López" />
<people id="6" name="Laura" surname="Laredo" />
<people id="7" name="Perico" surname="Palotes" />
<people id="8" name="Patricia" surname="Pérez" />
<people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" />
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Sultán" kind="Gato" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
</dataset>
\ No newline at end of file
......@@ -15,4 +15,15 @@
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Pancho" kind="Perro" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
</dataset>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT dataset (people*, users*)>
<!ELEMENT dataset (people*, users*, pets*)>
<!ELEMENT people EMPTY>
<!ELEMENT users EMPTY>
<!ELEMENT pets EMPTY>
<!ATTLIST people
id CDATA #IMPLIED
name CDATA #IMPLIED
......@@ -12,3 +13,10 @@
password CDATA #IMPLIED
role CDATA #IMPLIED
>
<!ATTLIST pets
id CDATA #IMPLIED
name CDATA #IMPLIED
kind CDATA #IMPLIED
owner CDATA #IMPLIED
>
\ No newline at end of file
......@@ -13,6 +13,17 @@
<people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" />
<pets id="1" name="Laika" kind="Perro" owner="1" />
<pets id="2" name="Alaska" kind="Gato" owner="1" />
<pets id="3" name="Lucky" kind="Perro" owner="1" />
<pets id="4" name="Luck" kind="Gato" owner="1" />
<pets id="5" name="Pancho" kind="Perro" owner="1" />
<pets id="6" name="Chikita" kind="Gato" owner="1" />
<pets id="7" name="Bethoven" kind="Perro" owner="1" />
<pets id="8" name="Bella" kind="Perro" owner="1" />
<pets id="9" name="Puppi" kind="Gato" owner="1" />
<pets id="10" name="Piolin" kind="Perro" owner="1" />
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
</dataset>
\ No newline at end of file
DROP TABLE Pets IF EXISTS;
DROP TABLE People IF EXISTS;
DROP TABLE Users IF EXISTS;
......@@ -11,3 +11,12 @@ CREATE TABLE users (
role VARCHAR(5) NOT NULL,
PRIMARY KEY (login)
);
CREATE TABLE pets (
id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
name varchar(50) NOT NULL,
kind varchar(100) NOT NULL,
owner INTEGER NOT NULL,
FOREIGN KEY (owner) REFERENCES people(id) ON DELETE CASCADE,
PRIMARY KEY (id)
);
\ No newline at end of file
......@@ -342,9 +342,18 @@ const routes = [
{
path: 'people',
loadChildren: () => __webpack_require__.e(/*! import() | modules-people-people-module */ "modules-people-people-module").then(__webpack_require__.bind(null, /*! ./modules/people/people.module */ "./src/app/modules/people/people.module.ts")).then(m => m.PeopleModule)
},
{
path: 'listPets/:person',
redirectTo: ':person',
pathMatch: 'full'
},
{
path: ':person',
loadChildren: () => __webpack_require__.e(/*! import() | modules-pets-pets-module */ "modules-pets-pets-module").then(__webpack_require__.bind(null, /*! ./modules/pets/pets.module */ "./src/app/modules/pets/pets.module.ts")).then(m => m.PetsModule)
}
]
}
},
];
let AppRoutingModule = class AppRoutingModule {
};
......@@ -478,7 +487,7 @@ AppModule = tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
declarations: [
_app_component__WEBPACK_IMPORTED_MODULE_4__["AppComponent"],
_components_login_panel_login_panel_component__WEBPACK_IMPORTED_MODULE_5__["LoginPanelComponent"],
_components_main_panel_main_panel_component__WEBPACK_IMPORTED_MODULE_6__["MainPanelComponent"]
_components_main_panel_main_panel_component__WEBPACK_IMPORTED_MODULE_6__["MainPanelComponent"],
],
imports: [
_app_routing_module__WEBPACK_IMPORTED_MODULE_3__["AppRoutingModule"],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -736,6 +736,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return m.PeopleModule;
});
}
}, {
path: 'listPets/:person',
redirectTo: ':person',
pathMatch: 'full'
}, {
path: ':person',
loadChildren: function loadChildren() {
return __webpack_require__.e(
/*! import() | modules-pets-pets-module */
"modules-pets-pets-module").then(__webpack_require__.bind(null,
/*! ./modules/pets/pets.module */
"./src/app/modules/pets/pets.module.ts")).then(function (m) {
return m.PetsModule;
});
}
}]
}];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,7 +22,7 @@ __webpack_require__.r(__webpack_exports__);
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = ("<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n");
/* harmony default export */ __webpack_exports__["default"] = ("<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n <button class=\"btn btn-success pets \" (click)=\"pets(person)\">Pets</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n");
/***/ }),
......@@ -161,6 +161,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PeopleListComponent", function() { return PeopleListComponent; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @angular/core */ "./node_modules/@angular/core/fesm2015/core.js");
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @angular/router */ "./node_modules/@angular/router/fesm2015/router.js");
/*
* DAA Example
*
......@@ -181,8 +182,10 @@ __webpack_require__.r(__webpack_exports__);
*/
let PeopleListComponent = class PeopleListComponent {
constructor() {
constructor(router) {
this.router = router;
this.people = [];
this.edit = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
this.delete = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
......@@ -193,7 +196,13 @@ let PeopleListComponent = class PeopleListComponent {
onDelete(person) {
this.delete.emit(person);
}
pets(person) {
this.router.navigate(['//listPets', person.id]);
}
};
PeopleListComponent.ctorParameters = () => [
{ type: _angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"] }
];
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])(),
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", Array)
......@@ -212,7 +221,7 @@ PeopleListComponent = tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
template: tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(/*! raw-loader!./people-list.component.html */ "./node_modules/raw-loader/dist/cjs.js!./src/app/modules/people/components/people-list/people-list.component.html")).default,
styles: [tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(/*! ./people-list.component.scss */ "./src/app/modules/people/components/people-list/people-list.component.scss")).default]
}),
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [])
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [_angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]])
], PeopleListComponent);
......
......@@ -41,7 +41,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
/* harmony default export */
__webpack_exports__["default"] = "<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n";
__webpack_exports__["default"] = "<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n <button class=\"btn btn-success pets \" (click)=\"pets(person)\">Pets</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n";
/***/
},
......@@ -247,6 +247,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
/*! @angular/core */
"./node_modules/@angular/core/fesm2015/core.js");
/* harmony import */
var _angular_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
/*! @angular/router */
"./node_modules/@angular/router/fesm2015/router.js");
/*
* DAA Example
*
......@@ -270,9 +276,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
var PeopleListComponent =
/*#__PURE__*/
function () {
function PeopleListComponent() {
function PeopleListComponent(router) {
_classCallCheck(this, PeopleListComponent);
this.router = router;
this.people = [];
this.edit = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
this.delete = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
......@@ -288,11 +295,22 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
value: function onDelete(person) {
this.delete.emit(person);
}
}, {
key: "pets",
value: function pets(person) {
this.router.navigate(['//listPets', person.id]);
}
}]);
return PeopleListComponent;
}();
PeopleListComponent.ctorParameters = function () {
return [{
type: _angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]
}];
};
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", Array)], PeopleListComponent.prototype, "people", void 0);
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"])], PeopleListComponent.prototype, "edit", void 0);
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"])], PeopleListComponent.prototype, "delete", void 0);
......@@ -304,7 +322,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
styles: [tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(
/*! ./people-list.component.scss */
"./src/app/modules/people/components/people-list/people-list.component.scss")).default]
}), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [])], PeopleListComponent);
}), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [_angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]])], PeopleListComponent);
/***/
},
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -64,7 +64,7 @@
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module"}[chunkId]||chunkId) + "-es2015.js"
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module","modules-pets-pets-module":"modules-pets-pets-module"}[chunkId]||chunkId) + "-es2015.js"
/******/ }
/******/
/******/ // The require function
......
This diff is collapsed.
......@@ -64,7 +64,7 @@
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module"}[chunkId]||chunkId) + "-es5.js"
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module","modules-pets-pets-module":"modules-pets-pets-module"}[chunkId]||chunkId) + "-es5.js"
/******/ }
/******/
/******/ // The require function
......
This diff is collapsed.
......@@ -342,9 +342,18 @@ const routes = [
{
path: 'people',
loadChildren: () => __webpack_require__.e(/*! import() | modules-people-people-module */ "modules-people-people-module").then(__webpack_require__.bind(null, /*! ./modules/people/people.module */ "./src/app/modules/people/people.module.ts")).then(m => m.PeopleModule)
},
{
path: 'listPets/:person',
redirectTo: ':person',
pathMatch: 'full'
},
{
path: ':person',
loadChildren: () => __webpack_require__.e(/*! import() | modules-pets-pets-module */ "modules-pets-pets-module").then(__webpack_require__.bind(null, /*! ./modules/pets/pets.module */ "./src/app/modules/pets/pets.module.ts")).then(m => m.PetsModule)
}
]
}
},
];
let AppRoutingModule = class AppRoutingModule {
};
......@@ -478,7 +487,7 @@ AppModule = tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
declarations: [
_app_component__WEBPACK_IMPORTED_MODULE_4__["AppComponent"],
_components_login_panel_login_panel_component__WEBPACK_IMPORTED_MODULE_5__["LoginPanelComponent"],
_components_main_panel_main_panel_component__WEBPACK_IMPORTED_MODULE_6__["MainPanelComponent"]
_components_main_panel_main_panel_component__WEBPACK_IMPORTED_MODULE_6__["MainPanelComponent"],
],
imports: [
_app_routing_module__WEBPACK_IMPORTED_MODULE_3__["AppRoutingModule"],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -736,6 +736,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return m.PeopleModule;
});
}
}, {
path: 'listPets/:person',
redirectTo: ':person',
pathMatch: 'full'
}, {
path: ':person',
loadChildren: function loadChildren() {
return __webpack_require__.e(
/*! import() | modules-pets-pets-module */
"modules-pets-pets-module").then(__webpack_require__.bind(null,
/*! ./modules/pets/pets.module */
"./src/app/modules/pets/pets.module.ts")).then(function (m) {
return m.PetsModule;
});
}
}]
}];
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,7 +22,7 @@ __webpack_require__.r(__webpack_exports__);
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = ("<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n");
/* harmony default export */ __webpack_exports__["default"] = ("<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n <button class=\"btn btn-success pets \" (click)=\"pets(person)\">Pets</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n");
/***/ }),
......@@ -161,6 +161,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PeopleListComponent", function() { return PeopleListComponent; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @angular/core */ "./node_modules/@angular/core/fesm2015/core.js");
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @angular/router */ "./node_modules/@angular/router/fesm2015/router.js");
/*
* DAA Example
*
......@@ -181,8 +182,10 @@ __webpack_require__.r(__webpack_exports__);
*/
let PeopleListComponent = class PeopleListComponent {
constructor() {
constructor(router) {
this.router = router;
this.people = [];
this.edit = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
this.delete = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
......@@ -193,7 +196,13 @@ let PeopleListComponent = class PeopleListComponent {
onDelete(person) {
this.delete.emit(person);
}
pets(person) {
this.router.navigate(['//listPets', person.id]);
}
};
PeopleListComponent.ctorParameters = () => [
{ type: _angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"] }
];
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])(),
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", Array)
......@@ -212,7 +221,7 @@ PeopleListComponent = tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
template: tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(/*! raw-loader!./people-list.component.html */ "./node_modules/raw-loader/dist/cjs.js!./src/app/modules/people/components/people-list/people-list.component.html")).default,
styles: [tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(/*! ./people-list.component.scss */ "./src/app/modules/people/components/people-list/people-list.component.scss")).default]
}),
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [])
tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [_angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]])
], PeopleListComponent);
......
......@@ -41,7 +41,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
/* harmony default export */
__webpack_exports__["default"] = "<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n";
__webpack_exports__["default"] = "<!--\r\n ~ DAA Example\r\n ~\r\n ~ Copyright (C) 2019 - Miguel Reboiro-Jato.\r\n ~\r\n ~ This program is free software: you can redistribute it and/or modify\r\n ~ it under the terms of the GNU General Public License as published by\r\n ~ the Free Software Foundation, either version 3 of the License, or\r\n ~ (at your option) any later version.\r\n ~\r\n ~ This program is distributed in the hope that it will be useful,\r\n ~ but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n ~ GNU General Public License for more details.\r\n ~\r\n ~ You should have received a copy of the GNU General Public License\r\n ~ along with this program. If not, see <http://www.gnu.org/licenses/>.\r\n -->\r\n\r\n<table id=\"people-list\" class=\"table\">\r\n <thead>\r\n <tr class=\"row\">\r\n <th class=\"col-sm-4\">Nombre</th>\r\n <th class=\"col-sm-5\">Apellido</th>\r\n <th class=\"col-sm-3\">&nbsp;</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let person of people\" class=\"row\" id=\"person-{{person.id}}\">\r\n <td class=\"col-sm-4 name\">{{person.name}}</td>\r\n <td class=\"col-sm-5 surname\">{{person.surname}}</td>\r\n <td class=\"col-sm-3\">\r\n <button class=\"btn btn-primary edit\" (click)=\"onEdit(person)\">Edit</button>\r\n <button class=\"btn btn-warning delete\" (click)=\"onDelete(person)\">Delete</button>\r\n <button class=\"btn btn-success pets \" (click)=\"pets(person)\">Pets</button>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n";
/***/
},
......@@ -247,6 +247,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
/*! @angular/core */
"./node_modules/@angular/core/fesm2015/core.js");
/* harmony import */
var _angular_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
/*! @angular/router */
"./node_modules/@angular/router/fesm2015/router.js");
/*
* DAA Example
*
......@@ -270,9 +276,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
var PeopleListComponent =
/*#__PURE__*/
function () {
function PeopleListComponent() {
function PeopleListComponent(router) {
_classCallCheck(this, PeopleListComponent);
this.router = router;
this.people = [];
this.edit = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
this.delete = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
......@@ -288,11 +295,22 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
value: function onDelete(person) {
this.delete.emit(person);
}
}, {
key: "pets",
value: function pets(person) {
this.router.navigate(['//listPets', person.id]);
}
}]);
return PeopleListComponent;
}();
PeopleListComponent.ctorParameters = function () {
return [{
type: _angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]
}];
};
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", Array)], PeopleListComponent.prototype, "people", void 0);
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"])], PeopleListComponent.prototype, "edit", void 0);
tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])(), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"])], PeopleListComponent.prototype, "delete", void 0);
......@@ -304,7 +322,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
styles: [tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"](__webpack_require__(
/*! ./people-list.component.scss */
"./src/app/modules/people/components/people-list/people-list.component.scss")).default]
}), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [])], PeopleListComponent);
}), tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"]("design:paramtypes", [_angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]])], PeopleListComponent);
/***/
},
......
......@@ -64,7 +64,7 @@
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module"}[chunkId]||chunkId) + "-es2015.js"
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module","modules-pets-pets-module":"modules-pets-pets-module"}[chunkId]||chunkId) + "-es2015.js"
/******/ }
/******/
/******/ // The require function
......
......@@ -64,7 +64,7 @@
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module"}[chunkId]||chunkId) + "-es5.js"
/******/ return __webpack_require__.p + "" + ({"modules-people-people-module":"modules-people-people-module","modules-pets-pets-module":"modules-pets-pets-module"}[chunkId]||chunkId) + "-es5.js"
/******/ }
/******/
/******/ // The require function
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>DAAExample</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Authorization</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET, POST, DELETE, PUT</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/rest/*</url-pattern>
</filter-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/rest/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
<role-name>USER</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin Area</web-resource-name>
<url-pattern>/rest/people/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
<!-- Security roles referenced by this web application -->
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>USER</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>DAAExample</realm-name>
</login-config>
</web-app>
\ No newline at end of file
<!--
~ DAA Example
~
~ Copyright (C) 2019 - Miguel Reboiro-Jato.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DAA Example</title>
<base href=".">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
<script src="runtime-es2015.js" type="module"></script><script src="runtime-es5.js" nomodule defer></script><script src="polyfills-es5.js" nomodule defer></script><script src="polyfills-es2015.js" type="module"></script><script src="styles-es2015.js" type="module"></script><script src="styles-es5.js" nomodule defer></script><script src="vendor-es2015.js" type="module"></script><script src="vendor-es5.js" nomodule defer></script><script src="main-es2015.js" type="module"></script><script src="main-es5.js" nomodule defer></script></body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
es\uvigo\esei\daa\rest\PeopleResource.class
es\uvigo\esei\daa\dao\PeopleDAO.class
es\uvigo\esei\daa\rest\PetsResource.class
es\uvigo\esei\daa\dao\PetsDAO.class
es\uvigo\esei\daa\entities\Pet.class
es\uvigo\esei\daa\entities\User.class
es\uvigo\esei\daa\dao\UsersDAO.class
es\uvigo\esei\daa\dao\DAOException.class
es\uvigo\esei\daa\DAAExampleApplication.class
es\uvigo\esei\daa\dao\DAO.class
es\uvigo\esei\daa\entities\Person.class
es\uvigo\esei\daa\rest\UsersResource.class
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\entities\User.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\rest\UsersResource.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\rest\PetsResource.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\DAAExampleApplication.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\entities\Pet.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\dao\PetsDAO.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\dao\UsersDAO.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\dao\DAO.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\main\java\es\uvigo\esei\daa\entities\Person.java
......
es\uvigo\esei\daa\listeners\DbManagementTestExecutionListener.class
es\uvigo\esei\daa\rest\PeopleResourceTest.class
es\uvigo\esei\daa\filters\AuthorizationFilter.class
es\uvigo\esei\daa\listeners\DbManagementAction.class
es\uvigo\esei\daa\filters\AuthorizationFilter$UserSecurityContext.class
......@@ -8,8 +7,8 @@ es\uvigo\esei\daa\suites\AcceptanceTestSuite.class
es\uvigo\esei\daa\util\DatabaseQueryUnitTest.class
es\uvigo\esei\daa\listeners\DbManagement.class
es\uvigo\esei\daa\web\pages\MainPage$PersonForm.class
es\uvigo\esei\daa\suites\IntegrationTestSuite.class
es\uvigo\esei\daa\web\pages\MainPage$PeopleTable.class
es\uvigo\esei\daa\entities\PetUnitTest.class
es\uvigo\esei\daa\dao\PeopleDAOUnitTest.class
es\uvigo\esei\daa\listeners\DbManagementTestExecutionListener$1.class
es\uvigo\esei\daa\matchers\IsEqualToPerson.class
......@@ -23,11 +22,9 @@ es\uvigo\esei\daa\listeners\ApplicationContextBinding$None.class
es\uvigo\esei\daa\filters\AuthorizationFilter$1.class
es\uvigo\esei\daa\filters\AuthorizationFilter$UserSecurityContext$1.class
es\uvigo\esei\daa\listeners\ApplicationContextBinding.class
es\uvigo\esei\daa\DAAExampleTestApplication.class
es\uvigo\esei\daa\matchers\IsEqualToUser.class
es\uvigo\esei\daa\web\pages\MainPage.class
es\uvigo\esei\daa\dao\PeopleDAOTest.class
es\uvigo\esei\daa\rest\UsersResourceTest.class
es\uvigo\esei\daa\util\JSWaiter.class
es\uvigo\esei\daa\matchers\IsEqualToEntity.class
es\uvigo\esei\daa\web\PeopleWebTest.class
......
C:\Users\Noelia\Desktop\DAA\daaexample\src\test\java\es\uvigo\esei\daa\dao\PeopleDAOTest.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\test\java\es\uvigo\esei\daa\entities\PetUnitTest.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\test\java\es\uvigo\esei\daa\rest\UsersResourceTest.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\test\java\es\uvigo\esei\daa\suites\UnitTestSuite.java
C:\Users\Noelia\Desktop\DAA\daaexample\src\test\java\es\uvigo\esei\daa\entities\PersonUnitTest.java
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia Site Renderer 1.6 at 2020-03-18 -->
<!-- Generated by Apache Maven Doxia Site Renderer 1.6 at 2020-03-19 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
......@@ -10,7 +10,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20200318" />
<meta name="Date-Revision-yyyymmdd" content="20200319" />
<meta http-equiv="Content-Language" content="es" />
</head>
......@@ -24,7 +24,7 @@
<div class="xleft">
<span id="publishDate">Publicado el: 2020-03-18</span>
<span id="publishDate">Publicado el: 2020-03-19</span>
&nbsp;| <span id="projectVersion">Versión: 0.2.0-SNAPSHOT</span>
</div>
<div class="xright">
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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