@Test
  public void all_organisations_returned() {
    databaseHelper.addObject(
        "mntner: TEST-MNT\nmnt-by:TEST-MNT\nauth: SSO [email protected]\nsource:test");
    final RpslObject org1 =
        RpslObject.parse(
            "" + "organisation: ORG-TST1-TEST\n" + "mnt-by: TEST-MNT\n" + "source: TEST");
    databaseHelper.addObject(org1);
    final RpslObject org2 =
        RpslObject.parse(
            "" + "organisation: ORG-MD5-TEST\n" + "mnt-by: TEST-MNT\n" + "source: TEST");
    databaseHelper.addObject(org2);

    final WhoisResources result =
        RestTest.target(
                getPort(),
                "api/user/ed7cd420-6402-11e3-949a-0800200c9a66/organisations",
                null,
                apiKey)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .get(WhoisResources.class);

    final List<WhoisObject> whoisObjects = result.getWhoisObjects();
    assertThat(whoisObjects, hasSize(2));

    assertThat(
        whoisObjectMapper.map(whoisObjects.get(0), FormattedClientAttributeMapper.class), is(org2));
    assertThat(
        whoisObjectMapper.map(whoisObjects.get(1), FormattedClientAttributeMapper.class), is(org1));
  }
  @Test
  public void isMaintainedInRirSpace_ipv6() {
    final AuthoritativeResource resourceData =
        AuthoritativeResource.loadFromScanner(
            logger,
            "RIPE-GRS",
            new Scanner(
                ""
                    + "ripencc|DE|ipv6|2001:608::|32|19990812|allocated\n"
                    + "ripencc|NL|ipv6|2001:610::|32|19990819|allocated\n"));

    assertThat(resourceData.isEmpty(), is(false));

    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2001::")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INET6NUM, ciString("2001::")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2002:608::")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INET6NUM, ciString("2002:608::")),
        is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2001:608::")), is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INET6NUM, ciString("2001:608::/32")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2001:608:abcd::")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INET6NUM, ciString("2001:608:abcd::")),
        is(true));
  }
 @Test
 public void isMaintainedInRirSpace_invalid_resource() {
   final AuthoritativeResource resourceData =
       AuthoritativeResource.loadFromScanner(logger, "RIPE-GRS", new Scanner(""));
   assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: 12345")), is(false));
   assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 0")), is(false));
   assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 0")), is(false));
   assertThat(resourceData.isEmpty(), is(true));
 }
 @Test
 public void isMaintainedInRirSpace_empty_file() {
   final AuthoritativeResource resourceData =
       AuthoritativeResource.loadFromScanner(logger, "RIPE-GRS", new Scanner(""));
   assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS123")), is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 10.0.0.0 - 10.255.255.255")),
       is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2001::/20")), is(false));
   assertThat(resourceData.isEmpty(), is(true));
 }
  @Test
  public void isMaintainedInRirSpace_aut_num() {
    final AuthoritativeResource resourceData =
        AuthoritativeResource.loadFromScanner(
            logger,
            "RIPE-GRS",
            new Scanner(
                ""
                    + "ripencc|EU|asn|7|1|19930901|allocated\n"
                    + "ripencc|EU|asn|28|10|19930901|allocated\n"));

    assertThat(resourceData.isEmpty(), is(false));

    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS6")), is(false));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS6")), is(false));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS7")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS7")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS8")), is(false));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS8")), is(false));

    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS27")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS27")), is(false));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS28")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS28")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS29")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS29")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS37")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS37")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS38")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS38")), is(false));
  }
  @Test
  public void organisations_w_mnt_by_and_ref_RS_found_via_mnt_ref() {
    databaseHelper.addObject("mntner: TEST-MNT\nmnt-by:TEST-MNT\nauth: SSO [email protected]");
    databaseHelper.addObject(
        "mntner: RIPE-NCC-HM-MNT\nmnt-by:RIPE-NCC-HM-MNT\nauth: SSO [email protected]");
    final RpslObject organisation =
        RpslObject.parse(
            ""
                + "organisation: ORG-TST-TEST\n"
                + "mnt-ref: TEST-MNT\n"
                + "mnt-ref: RIPE-NCC-HM-MNT\n"
                + "mnt-by: RIPE-NCC-HM-MNT\n"
                + "source: TEST");
    databaseHelper.addObject(organisation);

    final WhoisResources result =
        RestTest.target(
                getPort(),
                "api/user/ed7cd420-6402-11e3-949a-0800200c9a66/organisations",
                null,
                apiKey)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .get(WhoisResources.class);

    final RpslObject resultOrg =
        whoisObjectMapper.map(
            result.getWhoisObjects().get(0), FormattedClientAttributeMapper.class);

    assertThat(resultOrg, is(organisation));
  }
  @Test
  public void organisation_only_added_once() {
    databaseHelper.addObject("mntner: TEST-MNT\nmnt-by:TEST-MNT\nauth: SSO [email protected]");
    final RpslObject organisation =
        RpslObject.parse(
            ""
                + "organisation: ORG-TST-TEST\n"
                + "mnt-by: TEST-MNT\n"
                + "mnt-by: TEST-MNT\n"
                + "source: TEST");
    databaseHelper.addObject(organisation);

    final WhoisResources result =
        RestTest.target(
                getPort(),
                "api/user/906635c2-0405-429a-800b-0602bd716124/organisations",
                null,
                apiKey)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .get(WhoisResources.class);

    final List<WhoisObject> whoisObjects = result.getWhoisObjects();
    assertThat(whoisObjects, hasSize(1));

    final RpslObject resultOrg =
        whoisObjectMapper.map(whoisObjects.get(0), FormattedClientAttributeMapper.class);

    assertThat(resultOrg, is(organisation));
  }
  @Test
  public void only_organisations_returned() {
    databaseHelper.addObject("mntner: TEST-MNT\nmnt-by:TEST-MNT\nauth: SSO [email protected]");
    final RpslObject organisation =
        RpslObject.parse(
            ""
                + "organisation: ORG-TST-TEST\n"
                + "mnt-ref: TEST-MNT\n"
                + "mnt-by: TEST-MNT\n"
                + "source: TEST");
    databaseHelper.addObject(organisation);
    databaseHelper.addObject("person: Test Person\nnic-hdl: TST-TEST\nmnt-by: TEST-MNT");

    final WhoisResources result =
        RestTest.target(
                getPort(),
                "api/user/8ffe29be-89ef-41c8-ba7f-0e1553a623e5/organisations",
                null,
                apiKey)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .get(WhoisResources.class);

    final List<WhoisObject> whoisObjects = result.getWhoisObjects();
    assertThat(whoisObjects, hasSize(1));

    final RpslObject resultOrg =
        whoisObjectMapper.map(whoisObjects.get(0), FormattedClientAttributeMapper.class);

    assertThat(resultOrg, is(organisation));
  }
  @Test
  public void load_country_ignored() {
    final AuthoritativeResource resourceData =
        AuthoritativeResource.loadFromScanner(
            logger,
            "RIPE-GRS",
            new Scanner(
                ""
                    + "ripencc|*|asn|7|1|19930901|allocated\n"
                    + "ripencc|EU|asn|28|1|19930901|allocated\n"));

    assertThat(resourceData.getNrAutNums(), is(1));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS7")), is(false));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS28")), is(true));
    assertThat(resourceData.isEmpty(), is(false));
  }
  @Test(expected = IllegalArgumentException.class)
  public void add_to_index_empty_ifaddr() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr:\n");
    RpslObjectInfo rpslObjectInfo = new RpslObjectInfo(1, ObjectType.INET_RTR, rpslObject.getKey());

    subject.addToIndex(
        whoisTemplate, rpslObjectInfo, rpslObject, getIfAddrAttributeAsString(rpslObject));
  }
 @Test
 public void isMaintainedInRirSpace_unknown_data() {
   final AuthoritativeResource resourceData = AuthoritativeResource.unknown();
   assertThat(resourceData.isEmpty(), is(true));
   assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("aut-num: AS6")), is(false));
   assertThat(resourceData.isMaintainedInRirSpace(ObjectType.AUT_NUM, ciString("AS6")), is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 1.0.0.0 - 1.255.255.255")),
       is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(
           ObjectType.INETNUM, ciString("1.0.0.0 - 1.255.255.255")),
       is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(RpslObject.parse("inet6num: 2001::")), is(false));
   assertThat(
       resourceData.isMaintainedInRirSpace(ObjectType.INET6NUM, ciString("2001::")), is(false));
 }
  @Test
  public void validate_enum() {
    when(update.getUpdatedObject())
        .thenReturn(RpslObject.parse("" + "domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa"));

    subject.validate(update, updateContext);

    verifyZeroInteractions(ipv4DomainTree, ipv6DomainTree);
  }
  @Test
  public void validate_not_referenced() {
    final RpslObject object = RpslObject.parse("mntner: TST-MNT");
    when(update.getReferenceObject()).thenReturn(object);
    when(rpslObjectUpdateDao.getInvalidReferences(object))
        .thenReturn(Collections.<RpslAttribute, Set<String>>emptyMap());
    subject.validate(update, updateContext);

    verifyZeroInteractions(updateContext);
  }
  @Before
  public void setup() throws Exception {
    final RpslObject rootMntner =
        RpslObject.parse(
            ""
                + "mntner:  RIPE-NCC-HM-MNT\n"
                + "descr:   description\n"
                + "admin-c: TEST-RIPE\n"
                + "mnt-by:  RIPE-NCC-HM-MNT\n"
                + "referral-by: RIPE-NCC-HM-MNT\n"
                + "upd-to:  [email protected]\n"
                + "auth:    MD5-PW $1$/7f2XnzQ$p5ddbI7SXq4z4yNrObFS/0 # emptypassword"
                + "changed: [email protected] 20120707\n"
                + "source:  TEST");

    final RpslObject adminPerson =
        RpslObject.parse(
            ""
                + "person:  Admin Person\n"
                + "address: Admin Road\n"
                + "address: Town\n"
                + "address: UK\n"
                + "phone:   +44 282 411141\n"
                + "nic-hdl: TEST-RIPE\n"
                + "mnt-by:  TST-MNT\n"
                + "changed: [email protected] 20120101\n"
                + "source:  TEST");

    final RpslObject normalMntner =
        RpslObject.parse(
            ""
                + "mntner:  TST-MNT\n"
                + "descr:   description\n"
                + "admin-c: TEST-RIPE\n"
                + "mnt-by:  TST-MNT\n"
                + "referral-by: TST-MNT\n"
                + "upd-to:  [email protected]\n"
                + "auth:    MD5-PW $1$fU9ZMQN9$QQtm3kRqZXWAuLpeOiLN7. # update\n"
                + "changed: [email protected] 20120707\n"
                + "source:  TEST");

    databaseHelper.addObjects(Lists.newArrayList(rootMntner, adminPerson, normalMntner));
  }
  @Test
  public void remove_from_index_different_inetrtr() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr: 10.2.3.4 masklen 32");
    addObject(rpslObject);
    checkRows(1);

    subject.removeFromIndex(
        whoisTemplate, new RpslObjectInfo(2, ObjectType.INET_RTR, "another inet-rtr"));

    checkRows(1);
  }
  @Test
  public void isMaintainedInRirSpace_no_resource() {
    final AuthoritativeResource resourceData =
        AuthoritativeResource.loadFromScanner(logger, "RIPE-GRS", new Scanner(""));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("mntner: DEV-MNT")), is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(
            RpslObject.parse("person: Test Person\nnic-hdl: TP1-TEST")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("organisation: ORG-TOL1-TEST")),
        is(true));

    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.MNTNER, ciString("12345")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.PERSON, ciString("0")), is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.ORGANISATION, ciString("0")), is(true));

    assertThat(resourceData.isEmpty(), is(true));
  }
  @Before
  public void startupWhoisServer() throws Exception {
    databaseHelper.addObject(RpslObject.parse("mntner:RIPE-NCC-MNT\nnic-hdl:AP111-RIPE"));
    databaseHelper.addObject(
        RpslObject.parse(
            ""
                + "role:         Asia Pacific Network Information Centre\n"
                + "address:      APNIC, see http://www.apnic.net\n"
                + "e-mail:       [email protected]\n"
                + "admin-c:      APNC1-RIPE\n"
                + "tech-c:       APNC1-RIPE\n"
                + "nic-hdl:      APNC1-RIPE\n"
                + "remarks:      For more information on APNIC assigned blocks, connect\n"
                + "remarks:      to APNIC's whois database, whois.apnic.net.\n"
                + "mnt-by:       RIPE-NCC-MNT\n"
                + "changed:      [email protected] 20010411\n"
                + "source:       RIPE"));

    queryServer.start();
  }
  @Test
  public void findInIndex_not_found() throws Exception {
    IndexWithReference subject = new IndexWithReference(AttributeType.MNT_REF, "mnt_ref", "mnt_id");
    final RpslObject maintainer = RpslObject.parse("mntner:MNT-TEST\nmnt-by:MNT-TEST");
    final RpslObjectUpdateInfo objectInfo = rpslObjectUpdateDao.createObject(maintainer);

    assertThat(subject.findInIndex(whoisTemplate, objectInfo.getKey()).size(), is(0));
    assertThat(subject.findInIndex(whoisTemplate, objectInfo).size(), is(0));
    assertThat(
        subject.findInIndex(whoisTemplate, objectInfo, ObjectType.ORGANISATION).size(), is(0));
  }
  @Test
  public void addToIndex() throws Exception {
    IndexWithReference subject =
        new IndexWithReference(AttributeType.MNT_LOWER, "mnt_lower", "mnt_id");
    final RpslObject rpslObject = RpslObject.parse("mntner: RIPE-MNT\nmnt-by:RIPE-MNT");
    rpslObjectUpdateDao.createObject(rpslObject);
    final RpslObjectInfo maintainer = new RpslObjectInfo(1, ObjectType.MNTNER, "MNTNER");

    final int added = subject.addToIndex(whoisTemplate, maintainer, null, "RIPE-MNT");
    assertThat(added, is(1));
  }
  @Test
  public void validate_ipv6_domain_success() {
    when(update.getUpdatedObject())
        .thenReturn(RpslObject.parse("" + "domain: 0.0.0.0.8.f.7.0.1.0.0.2.ip6.arpa"));

    subject.validate(update, updateContext);

    verify(ipv6DomainTree).findFirstLessSpecific(Ipv6Resource.parse("2001:7f8::/48"));
    verify(ipv6DomainTree).findFirstMoreSpecific(Ipv6Resource.parse("2001:7f8::/48"));

    verifyZeroInteractions(ipv4DomainTree);
  }
  @Test
  public void validate_referenced_autnum() {
    final RpslObject object = RpslObject.parse("aut-num: AS1");

    when(update.getType()).thenReturn(ObjectType.AUT_NUM);
    when(update.hasOriginalObject()).thenReturn(true);
    when(update.getReferenceObject()).thenReturn(object);
    when(rpslObjectUpdateDao.isReferenced(object)).thenReturn(true);
    subject.validate(update, updateContext);

    verifyZeroInteractions(updateContext);
  }
  @Test
  public void validate_referenced() {
    final RpslObject object = RpslObject.parse("mntner: TST-MNT\nadmin-c: ADMIN-NC");

    when(update.getType()).thenReturn(ObjectType.MNTNER);
    when(update.hasOriginalObject()).thenReturn(true);
    when(update.getReferenceObject()).thenReturn(object);
    when(rpslObjectUpdateDao.isReferenced(object)).thenReturn(true);
    subject.validate(update, updateContext);

    verify(updateContext).addMessage(update, UpdateMessages.objectInUse(object));
  }
  @Test
  public void validate_ipv4_domain_success() {
    when(update.getUpdatedObject())
        .thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa"));

    subject.validate(update, updateContext);

    verify(ipv4DomainTree).findFirstLessSpecific(Ipv4Resource.parse("193.193.200.0/24"));
    verify(ipv4DomainTree).findFirstMoreSpecific(Ipv4Resource.parse("193.193.200.0/24"));

    verifyZeroInteractions(ipv6DomainTree);
  }
  @Test
  public void find_in_index() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr: 10.2.3.4 masklen 32");
    addObject(rpslObject);

    final List<RpslObjectInfo> found = subject.findInIndex(whoisTemplate, "10.2.3.4");

    assertThat(found.size(), is(1));
    final RpslObjectInfo objectInfo = found.get(0);
    assertThat(objectInfo.getObjectId(), is(1));
    assertThat(objectInfo.getObjectType(), is(ObjectType.INET_RTR));
    assertThat(objectInfo.getKey(), is("test"));
  }
  @Test
  public void add_to_index() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr: 10.2.3.4 masklen 32");
    RpslObjectInfo rpslObjectInfo = new RpslObjectInfo(1, ObjectType.INET_RTR, rpslObject.getKey());
    checkRows(0);

    final int rows =
        subject.addToIndex(
            whoisTemplate, rpslObjectInfo, rpslObject, getIfAddrAttributeAsString(rpslObject));

    assertThat(rows, is(1));
    checkRows(1);
  }
  @Test
  public void remove_from_index() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr: 10.2.3.4 masklen 32");
    checkRows(0);
    addObject(rpslObject);
    checkRows(1);

    subject.removeFromIndex(
        whoisTemplate,
        new RpslObjectInfo(getObjectId(rpslObject), ObjectType.INET_RTR, rpslObject.getKey()));

    checkRows(0);
  }
  @Test
  public void findInIndex_found() throws Exception {
    IndexWithReference subject = new IndexWithReference(AttributeType.MNT_REF, "mnt_ref", "mnt_id");
    final RpslObject maintainer = RpslObject.parse("mntner:MNT-TEST\nmnt-by:MNT-TEST");
    final RpslObjectUpdateInfo objectInfo = rpslObjectUpdateDao.createObject(maintainer);
    whoisTemplate.update(
        String.format(
            "INSERT INTO mnt_ref(object_id, mnt_id, object_type) VALUES(%s, %s, %s)",
            1, objectInfo.getObjectId(), 18));

    assertThat(subject.findInIndex(whoisTemplate, objectInfo.getKey()).size(), is(1));
    assertThat(subject.findInIndex(whoisTemplate, objectInfo).size(), is(1));
    assertThat(
        subject.findInIndex(whoisTemplate, objectInfo, ObjectType.ORGANISATION).size(), is(1));
  }
  @Test
  public void validate_ipv4_domain_more_specific() {
    when(update.getUpdatedObject())
        .thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa"));

    final Ipv4Resource moreSpecific = Ipv4Resource.parse("193.193.200.0/32");

    when(ipv4DomainTree.findFirstMoreSpecific(Ipv4Resource.parse("193.193.200.0/24")))
        .thenReturn(Lists.newArrayList(new Ipv4Entry(moreSpecific, 1)));

    subject.validate(update, updateContext);

    verify(updateContext)
        .addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.toString()));
    verifyZeroInteractions(ipv6DomainTree);
  }
Example #29
0
  @Test
  public void getUpdateStatus_failed() {
    final RpslObject rpslObject = RpslObject.parse("mntner: DEV-MNT");
    final Update update1 =
        new Update(new Paragraph(""), Operation.DELETE, Lists.<String>newArrayList(), rpslObject);
    final UpdateResult updateResult1 =
        new UpdateResult(
            update1,
            rpslObject,
            rpslObject,
            Action.DELETE,
            UpdateStatus.FAILED,
            new ObjectMessages(),
            0,
            false);

    final Update update2 =
        new Update(
            new Paragraph(""), Operation.UNSPECIFIED, Lists.<String>newArrayList(), rpslObject);

    final UpdateResult updateResult2 =
        new UpdateResult(
            update2,
            rpslObject,
            rpslObject,
            Action.MODIFY,
            UpdateStatus.FAILED,
            new ObjectMessages(),
            0,
            false);
    updateResults.add(updateResult1);
    updateResults.add(updateResult2);

    final Ack subject = new Ack(updateResults, ignoredParagraphs);

    assertThat(subject.getSucceededUpdates(), hasSize(0));
    assertThat(subject.getFailedUpdates(), contains(updateResult1, updateResult2));
    assertThat(subject.getIgnoredParagraphs(), hasSize(0));
    assertThat(subject.getUpdateStatus(), is(UpdateStatus.FAILED));
    assertThat(subject.getNrFound(), is(2));
    assertThat(subject.getNrProcessedsuccessfully(), is(0));
    assertThat(subject.getNrDelete(), is(0));
    assertThat(subject.getNrProcessedErrrors(), is(2));
    assertThat(subject.getNrDeleteErrors(), is(1));
  }
  @Test
  public void isMaintainedInRirSpace_ipv4() {
    final AuthoritativeResource resourceData =
        AuthoritativeResource.loadFromScanner(
            logger,
            "RIPE-GRS",
            new Scanner(
                ""
                    + "ripencc|FR|ipv4|2.0.0.0|1048576|20100712|allocated\n"
                    + "ripencc|EU|ipv4|2.16.0.0|524288|20100910|allocated\n"));

    assertThat(resourceData.isEmpty(), is(false));

    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 1.0.0.0 - 1.255.255.255")),
        is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(
            ObjectType.INETNUM, ciString("1.0.0.0 - 1.255.255.255")),
        is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2.0.0.0 - 2.0.0.0")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2.0.0.0 - 2.0.0.0")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2.0.0.0 - 2.0.0.1")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2.0.0.0 - 2.0.0.1")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2.0.0.1 - 2.0.0.1")),
        is(true));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2.0.0.1 - 2.0.0.1")),
        is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2/12")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2/12")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2/19")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2/19")), is(true));
    assertThat(resourceData.isMaintainedInRirSpace(RpslObject.parse("inetnum: 2/11")), is(false));
    assertThat(
        resourceData.isMaintainedInRirSpace(ObjectType.INETNUM, ciString("2/11")), is(false));
  }