Package net.pterodactylus.sone.core

Examples of net.pterodactylus.sone.core.Core


  }

  @Test
  public void testBookmarkingMissingPost() throws URISyntaxException {
    /* create mocks. */
    Core core = mock(Core.class);
    WebInterface webInterface = mock(WebInterface.class);
    when(webInterface.getCore()).thenReturn(core);
    HTTPRequest httpRequest = new HTTPRequestImpl(new URI("/ajax/bookmark.ajax"), "GET");
    FreenetRequest request = mock(FreenetRequest.class);
    when(request.getHttpRequest()).thenReturn(httpRequest);
View Full Code Here


    String type = request.getHttpRequest().getParam("type");
    if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) {
      return createErrorJsonObject("invalid-type");
    }
    String[] ids = request.getHttpRequest().getParam("id").split(" ");
    Core core = webInterface.getCore();
    for (String id : ids) {
      if (type.equals("post")) {
        Optional<Post> post = core.getPost(id);
        if (!post.isPresent()) {
          continue;
        }
        core.markPostKnown(post.get());
      } else if (type.equals("reply")) {
        Optional<PostReply> reply = core.getPostReply(id);
        if (!reply.isPresent()) {
          continue;
        }
        core.markReplyKnown(reply.get());
      } else if (type.equals("sone")) {
        Optional<Sone> sone = core.getSone(id);
        if (!sone.isPresent()) {
          continue;
        }
        core.markSoneKnown(sone.get());
      }
    }
    return createSuccessJsonObject();
  }
View Full Code Here

  @Test
  public void testLockingALocalSone() throws FcpException {
    Sone localSone = mock(Sone.class);
    when(localSone.getId()).thenReturn("LocalSone");
    when(localSone.isLocal()).thenReturn(true);
    Core core = mock(Core.class);
    when(core.getSone(eq("LocalSone"))).thenReturn(Optional.of(localSone));
    when(core.getLocalSone(eq("LocalSone"), anyBoolean())).thenReturn(localSone);
    SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get();

    LockSoneCommand lockSoneCommand = new LockSoneCommand(core);
    Response response = lockSoneCommand.execute(fields, null, null);
View Full Code Here

  }

  @Test(expected = FcpException.class)
  public void testLockingARemoteSone() throws FcpException {
    Sone removeSone = mock(Sone.class);
    Core core = mock(Core.class);
    when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(removeSone));
    SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get();

    LockSoneCommand lockSoneCommand = new LockSoneCommand(core);
    lockSoneCommand.execute(fields, null, null);
  }
View Full Code Here

    lockSoneCommand.execute(fields, null, null);
  }

  @Test(expected = FcpException.class)
  public void testMissingSone() throws FcpException {
    Core core = mock(Core.class);
    SimpleFieldSet fields = new SimpleFieldSetBuilder().get();

    LockSoneCommand lockSoneCommand = new LockSoneCommand(core);
    lockSoneCommand.execute(fields, null, null);
  }
View Full Code Here

  @Test
  public void testUnlockingALocalSone() throws FcpException {
    Sone localSone = mock(Sone.class);
    when(localSone.getId()).thenReturn("LocalSone");
    when(localSone.isLocal()).thenReturn(true);
    Core core = mock(Core.class);
    when(core.getSone(eq("LocalSone"))).thenReturn(Optional.of(localSone));
    when(core.getLocalSone(eq("LocalSone"), anyBoolean())).thenReturn(localSone);
    SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get();

    UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core);
    Response response = unlockSoneCommand.execute(fields, null, null);
View Full Code Here

  }

  @Test(expected = FcpException.class)
  public void testUnlockingARemoteSone() throws FcpException {
    Sone removeSone = mock(Sone.class);
    Core core = mock(Core.class);
    when(core.getSone(eq("RemoteSone"))).thenReturn(Optional.of(removeSone));
    SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "RemoteSone").get();

    UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core);
    unlockSoneCommand.execute(fields, null, null);
  }
View Full Code Here

    unlockSoneCommand.execute(fields, null, null);
  }

  @Test(expected = FcpException.class)
  public void testMissingSone() throws FcpException {
    Core core = mock(Core.class);
    SimpleFieldSet fields = new SimpleFieldSetBuilder().get();

    UnlockSoneCommand unlockSoneCommand = new UnlockSoneCommand(core);
    unlockSoneCommand.execute(fields, null, null);
  }
View Full Code Here

public class BookmarkAjaxPageTest {

  @Test
  public void testBookmarkingExistingPost() throws URISyntaxException {
    /* create mocks. */
    Core core = mock(Core.class);
    WebInterface webInterface = mock(WebInterface.class);
    when(webInterface.getCore()).thenReturn(core);
    HTTPRequest httpRequest = new HTTPRequestImpl(new URI("/ajax/bookmark.ajax?post=abc"), "GET");
    FreenetRequest request = mock(FreenetRequest.class);
    when(request.getHttpRequest()).thenReturn(httpRequest);
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.core.Core

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.