Search in sources :

Example 1 with AddNewPinParams

use of com.vsct.vboard.parameterFormat.AddNewPinParams in project vboard by voyages-sncf-technologies.

the class NotificationsControllerTest method postPinByAuthor.

public void postPinByAuthor(String[] labels) {
    // Impossible to test the addNotificationsFromPin call from this.pinController while mocking this.permission.
    // this.pinsController Test. Check if the right method is called with the right arguments, then we test the method called itself with the same arguments.
    NotificationsController notificationsControllerSpy = spy(this.notificationsController);
    PinsController pinsControllerSpy = new PinsController(jdbcTemplate, pinDAO, userDAO, commentDAO, likeDAO, labelDAO, savedPinDAO, elsClient, uploadsManager, permission, gamificationController, notificationsControllerSpy, proxyConfig);
    this.pinsController.deleteAllPins();
    pinsControllerSpy.addNewPin(new AddNewPinParams("title", "url", "im", "description", labels, "emailNotifFrom,firstname,lastname"));
    verify(notificationsControllerSpy).addNotificationsFromPin(eq(this.pinDAO.findAll().iterator().next().getPinId()), eq("a ajouté une épingle avec un label que vous suivez"));
}
Also used : AddNewPinParams(com.vsct.vboard.parameterFormat.AddNewPinParams)

Example 2 with AddNewPinParams

use of com.vsct.vboard.parameterFormat.AddNewPinParams in project vboard by voyages-sncf-technologies.

the class PinsControllerTest method update.

@Test
public void update() throws IOException {
    this.pinDAO.save(new Pin("0", "title", "", 0, "", "", "content", "auth", new DateTime()));
    String[] labels = { "label" };
    ArrayList<Pin> pins = new ArrayList<>();
    pins.add(this.pinDAO.findByPinId("0"));
    Mockito.doReturn(pins).when(elsClient).searchPinsById("0");
    try {
        this.pinsController.updatePin(new AddNewPinParams("titleupdate", "url", "imgtype", "contentupdate", labels, "auth"), "notfound");
        Assert.fail("Epingle non trouvee, sans erreur");
    } catch (VBoardException e) {
    }
    Assert.assertEquals(this.pinDAO.findByPinId("0").getPinTitle(), "title");
    this.pinsController.updatePin(new AddNewPinParams("titleupdate", "url", "imgtype", "contentupdate", labels, "author"), "0");
    Pin pin = this.pinDAO.findByPinId("0");
    Assert.assertEquals("titleupdate", pin.getPinTitle());
    Assert.assertEquals("url", pin.getHrefUrl());
    Assert.assertEquals("/pinImg/0.png", pin.getImgType());
    Assert.assertEquals("contentupdate", pin.getIndexableTextContent());
    Assert.assertEquals("label", pin.getLabels());
    Assert.assertEquals("auth", pin.getAuthor());
    this.pinsController.updatePin(new AddNewPinParams("titleupdate", "url", null, "contentupdate", labels, "author"), "0");
    pin = this.pinDAO.findByPinId("0");
    Assert.assertNull(pin.getImgType());
}
Also used : VBoardException(com.vsct.vboard.models.VBoardException) Pin(com.vsct.vboard.models.Pin) ArrayList(java.util.ArrayList) AddNewPinParams(com.vsct.vboard.parameterFormat.AddNewPinParams) DateTime(org.joda.time.DateTime) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

AddNewPinParams (com.vsct.vboard.parameterFormat.AddNewPinParams)2 Pin (com.vsct.vboard.models.Pin)1 VBoardException (com.vsct.vboard.models.VBoardException)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1