CorporateFilter implements Filter { @Override public Map<String, Object> artifactFilterFields() { final Map<String, Object> queryParams = new HashMap<String, Object>(); final DBRegExp regExp = getMongoRegExp(); if(regExp != null){ queryParams.put(DbArtifact.GROUPID_DB_FIELD, regExp); } return queryParams; } CorporateFilter(final DbOrganization organization); @Override boolean filter(final Object datamodelObj); boolean matches(final DbModule module); boolean matches(final DbArtifact artifact); boolean matches(final DbDependency dependency); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields(); DBRegExp getMongoRegExp();  }
@Test public void checkMongoRegExpGenerationForArtifacts(){ final DbOrganization organization = new DbOrganization(); organization.setName("testOrganization"); organization.getCorporateGroupIdPrefixes().add(GrapesTestUtils.CORPORATE_GROUPID_4TEST); organization.getCorporateGroupIdPrefixes().add("my.corporate.gid"); final CorporateFilter filter = new CorporateFilter(organization); Map<String, Object> params = filter.artifactFilterFields(); assertNotNull(params); assertEquals(1, params.size()); assertEquals(DbArtifact.GROUPID_DB_FIELD, params.keySet().iterator().next()); assertEquals(GrapesTestUtils.CORPORATE_GROUPID_4TEST + "*|my.corporate.gid*", params.values().iterator().next().toString()); }