Java Code Examples for org.example.ws.model.Greeting#setText()

The following examples show how to use org.example.ws.model.Greeting#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GreetingServiceTest.java    From spring-security-fundamentals with Apache License 2.0 8 votes vote down vote up
@Test
public void testUpdateNotFound() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.update(entity);
    } catch (NoResultException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected NoResultException",
            exception instanceof NoResultException);

}
 
Example 2
Source File: GreetingServiceTest.java    From spring-boot-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateWithId() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.create(entity);
    } catch (EntityExistsException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected EntityExistsException",
            exception instanceof EntityExistsException);

}
 
Example 3
Source File: GreetingServiceTest.java    From spring-security-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate() {

    Long id = new Long(1);

    Greeting entity = service.findOne(id);

    Assert.assertNotNull("failure - expected not null", entity);

    String updatedText = entity.getText() + " test";
    entity.setText(updatedText);
    Greeting updatedEntity = service.update(entity);

    Assert.assertNotNull("failure - expected not null", updatedEntity);
    Assert.assertEquals("failure - expected id attribute match", id,
            updatedEntity.getId());
    Assert.assertEquals("failure - expected text attribute match",
            updatedText, updatedEntity.getText());

}
 
Example 4
Source File: GreetingServiceTest.java    From spring-security-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateWithId() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.create(entity);
    } catch (EntityExistsException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected EntityExistsException",
            exception instanceof EntityExistsException);

}
 
Example 5
Source File: GreetingServiceTest.java    From spring-boot-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateNotFound() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.update(entity);
    } catch (NoResultException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected NoResultException",
            exception instanceof NoResultException);

}
 
Example 6
Source File: GreetingServiceTest.java    From spring-boot-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate() {

    Long id = new Long(1);

    Greeting entity = service.findOne(id);

    Assert.assertNotNull("failure - expected not null", entity);

    String updatedText = entity.getText() + " test";
    entity.setText(updatedText);
    Greeting updatedEntity = service.update(entity);

    Assert.assertNotNull("failure - expected not null", updatedEntity);
    Assert.assertEquals("failure - expected id attribute match", id,
            updatedEntity.getId());
    Assert.assertEquals("failure - expected text attribute match",
            updatedText, updatedEntity.getText());

}
 
Example 7
Source File: GreetingServiceTest.java    From spring-data-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateNotFound() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.update(entity);
    } catch (NoResultException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected NoResultException",
            exception instanceof NoResultException);

}
 
Example 8
Source File: GreetingServiceTest.java    From spring-data-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate() {

    Long id = new Long(1);

    Greeting entity = service.findOne(id);

    Assert.assertNotNull("failure - expected not null", entity);

    String updatedText = entity.getText() + " test";
    entity.setText(updatedText);
    Greeting updatedEntity = service.update(entity);

    Assert.assertNotNull("failure - expected not null", updatedEntity);
    Assert.assertEquals("failure - expected id attribute match", id,
            updatedEntity.getId());
    Assert.assertEquals("failure - expected text attribute match",
            updatedText, updatedEntity.getText());

}
 
Example 9
Source File: GreetingServiceTest.java    From spring-data-fundamentals with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateWithId() {

    Exception exception = null;

    Greeting entity = new Greeting();
    entity.setId(Long.MAX_VALUE);
    entity.setText("test");

    try {
        service.create(entity);
    } catch (EntityExistsException e) {
        exception = e;
    }

    Assert.assertNotNull("failure - expected exception", exception);
    Assert.assertTrue("failure - expected EntityExistsException",
            exception instanceof EntityExistsException);

}
 
Example 10
Source File: GreetingServiceBean.java    From spring-boot-fundamentals with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(
        propagation = Propagation.REQUIRED,
        readOnly = false)
@CachePut(
        value = "greetings",
        key = "#greeting.id")
public Greeting update(Greeting greeting) {
    logger.info("> update id:{}", greeting.getId());

    counterService.increment("method.invoked.greetingServiceBean.update");

    // Ensure the entity object to be updated exists in the repository to
    // prevent the default behavior of save() which will persist a new
    // entity if the entity matching the id does not exist
    Greeting greetingToUpdate = findOne(greeting.getId());
    if (greetingToUpdate == null) {
        // Cannot update Greeting that hasn't been persisted
        logger.error(
                "Attempted to update a Greeting, but the entity does not exist.");
        throw new NoResultException("Requested entity not found.");
    }

    greetingToUpdate.setText(greeting.getText());
    Greeting updatedGreeting = greetingRepository.save(greetingToUpdate);

    logger.info("< update id:{}", greeting.getId());
    return updatedGreeting;
}
 
Example 11
Source File: GreetingServiceBean.java    From spring-data-fundamentals with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(
        propagation = Propagation.REQUIRED,
        readOnly = false)
@CachePut(
        value = "greetings",
        key = "#greeting.id")
public Greeting update(Greeting greeting) {
    logger.info("> update id:{}", greeting.getId());

    counterService.increment("method.invoked.greetingServiceBean.update");

    // Ensure the entity object to be updated exists in the repository to
    // prevent the default behavior of save() which will persist a new
    // entity if the entity matching the id does not exist
    Greeting greetingToUpdate = findOne(greeting.getId());
    if (greetingToUpdate == null) {
        // Cannot update Greeting that hasn't been persisted
        logger.error(
                "Attempted to update a Greeting, but the entity does not exist.");
        throw new NoResultException("Requested entity not found.");
    }

    greetingToUpdate.setText(greeting.getText());
    Greeting updatedGreeting = greetingRepository.save(greetingToUpdate);

    logger.info("< update id:{}", greeting.getId());
    return updatedGreeting;
}
 
Example 12
Source File: GreetingServiceBean.java    From spring-security-fundamentals with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(
        propagation = Propagation.REQUIRED,
        readOnly = false)
@CachePut(
        value = "greetings",
        key = "#greeting.id")
public Greeting update(Greeting greeting) {
    logger.info("> update id:{}", greeting.getId());

    counterService.increment("method.invoked.greetingServiceBean.update");

    // Ensure the entity object to be updated exists in the repository to
    // prevent the default behavior of save() which will persist a new
    // entity if the entity matching the id does not exist
    Greeting greetingToUpdate = findOne(greeting.getId());
    if (greetingToUpdate == null) {
        // Cannot update Greeting that hasn't been persisted
        logger.error(
                "Attempted to update a Greeting, but the entity does not exist.");
        throw new NoResultException("Requested entity not found.");
    }

    greetingToUpdate.setText(greeting.getText());
    Greeting updatedGreeting = greetingRepository.save(greetingToUpdate);

    logger.info("< update id:{}", greeting.getId());
    return updatedGreeting;
}
 
Example 13
Source File: GreetingControllerMocksTest.java    From spring-boot-fundamentals with Apache License 2.0 4 votes vote down vote up
private Greeting getEntityStubData() {
    Greeting entity = new Greeting();
    entity.setId(1L);
    entity.setText("hello");
    return entity;
}
 
Example 14
Source File: GreetingServiceTest.java    From spring-boot-fundamentals with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreate() {

    Greeting entity = new Greeting();
    entity.setText("test");

    Greeting createdEntity = service.create(entity);

    Assert.assertNotNull("failure - expected not null", createdEntity);
    Assert.assertNotNull("failure - expected id attribute not null",
            createdEntity.getId());
    Assert.assertEquals("failure - expected text attribute match", "test",
            createdEntity.getText());

    Collection<Greeting> list = service.findAll();

    Assert.assertEquals("failure - expected size", 3, list.size());

}
 
Example 15
Source File: GreetingControllerMocksTest.java    From spring-security-fundamentals with Apache License 2.0 4 votes vote down vote up
private Greeting getEntityStubData() {
    Greeting entity = new Greeting();
    entity.setId(1L);
    entity.setText("hello");
    return entity;
}
 
Example 16
Source File: GreetingServiceTest.java    From spring-security-fundamentals with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreate() {

    Greeting entity = new Greeting();
    entity.setText("test");

    Greeting createdEntity = service.create(entity);

    Assert.assertNotNull("failure - expected not null", createdEntity);
    Assert.assertNotNull("failure - expected id attribute not null",
            createdEntity.getId());
    Assert.assertEquals("failure - expected text attribute match", "test",
            createdEntity.getText());

    Collection<Greeting> list = service.findAll();

    Assert.assertEquals("failure - expected size", 3, list.size());

}
 
Example 17
Source File: GreetingServiceTest.java    From spring-data-fundamentals with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreate() {

    Greeting entity = new Greeting();
    entity.setText("test");

    Greeting createdEntity = service.create(entity);

    Assert.assertNotNull("failure - expected not null", createdEntity);
    Assert.assertNotNull("failure - expected id attribute not null",
            createdEntity.getId());
    Assert.assertEquals("failure - expected text attribute match", "test",
            createdEntity.getText());

    Collection<Greeting> list = service.findAll();

    Assert.assertEquals("failure - expected size", 6, list.size());

}
 
Example 18
Source File: GreetingControllerMocksTest.java    From spring-data-fundamentals with Apache License 2.0 4 votes vote down vote up
private Greeting getEntityStubData() {
    Greeting entity = new Greeting();
    entity.setId(1L);
    entity.setText("hello");
    return entity;
}