src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
AuditFilter implements Filter { public static void audit(AuditLog auditLog) { if (AUDIT_LOG.isInfoEnabled() && auditLog != null) { AUDIT_LOG.info(auditLog.toString()); } } @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain);...
@Test public void testAudit() throws IOException, ServletException { AtlasRepositoryConfiguration.resetExcludedOperations(); when(servletRequest.getRequestURL()).thenReturn(new StringBuffer("api/atlas/types")); when(servletRequest.getMethod()).thenReturn("GET"); AuditFilter auditFilter = new AuditFilter(); auditFilter....
AuditFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { final long startTime = System.currentTimeMillis(); final Date requestTime = new Date(); final HttpServletRequest httpRequest = (HttpServletRequ...
@Test public void testAuditWithExcludedOperation() throws IOException, ServletException { AtlasRepositoryConfiguration.resetExcludedOperations(); when(configuration.getStringArray(AtlasRepositoryConfiguration.AUDIT_EXCLUDED_OPERATIONS)).thenReturn(new String[]{"GET:Version", "GET:Ping"}); when(servletRequest.getRequest...
AtlasClassificationType extends AtlasStructType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { for (AtlasClassificationType superType : superTypes) { ret = superType.validateValue(obj, objName, messages) && ret; } ret = validateTimeBo...
@Test public void testClassificationTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(classificationType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(classif...
ClassificationSearchProcessor extends SearchProcessor { @Override public List<AtlasVertex> execute() { if (LOG.isDebugEnabled()) { LOG.debug("==> ClassificationSearchProcessor.execute({})", context); } List<AtlasVertex> ret = new ArrayList<>(); AtlasPerfTracer perf = null; if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LO...
@Test(priority = -1) public void searchByALLTag() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setClassification(ALL_CLASSIFICATION_TYPES); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); ClassificationSea...
AtlasClassificationType extends AtlasStructType { public static boolean isValidTimeZone(final String timeZone) { final String DEFAULT_GMT_TIMEZONE = "GMT"; if (timeZone.equals(DEFAULT_GMT_TIMEZONE)) { return true; } else { String id = TimeZone.getTimeZone(timeZone).getID(); if (!id.equals(DEFAULT_GMT_TIMEZONE)) { retur...
@Test public void testClassificationTimebounderTimeZone() { assertTrue(isValidTimeZone("IST")); assertTrue(isValidTimeZone("JST")); assertTrue(isValidTimeZone("UTC")); assertTrue(isValidTimeZone("GMT")); assertTrue(isValidTimeZone("GMT+0")); assertTrue(isValidTimeZone("GMT-0")); assertTrue(isValidTimeZone("GMT+9:00"));...
AtlasMapType extends AtlasType { @Override public Map<Object, Object> createDefaultValue() { Map<Object, Object> ret = new HashMap<>(); Object key = keyType.createDefaultValue(); if ( key != null) { ret.put(key, valueType.createDefaultValue()); } return ret; } AtlasMapType(AtlasType keyType, AtlasType valueType); Atla...
@Test public void testMapTypeDefaultValue() { Map<Object, Object> defValue = intIntMapType.createDefaultValue(); assertEquals(defValue.size(), 1); }
ReactiveBus implements Bus { public static ReactiveBus create() { return new ReactiveBus(); } static ReactiveBus create(); @Override void send(final Event object); @Override @SuppressWarnings("unchecked") Flowable<Event> receive(); }
@Test public void shouldCreateBus() { Bus bus = ReactiveBus.create(); assertThat(bus).isNotNull(); }
Event { public static Event create() { return Event.builder().build(); } protected Event(String id, String name, Serializable data); protected Event(String id, String name); protected Event(Builder builder); protected Event(); static Event create(); static Builder id(final String id); String id(); static Builder na...
@Test public void shouldCreateEvent() { Event event = Event.create(); assertThat(event).isNotNull(); }
DataSourceController { @RequestMapping(method = RequestMethod.PUT) @ResponseBody public GetDatasourceResponse put(@PathVariable("tenant") String tenantId, @PathVariable("datasource") String dataSourceId, @RequestParam(value = "validate", required = false) Boolean validate, @Valid @RequestBody RestDataSourceDefinition d...
@Test public void testPutWithoutValidation() throws Exception { final String tenant = name.getMethodName(); tenantRegistry.createTenantContext(tenant); final RestDataSourceDefinition dataSourceDefinition = new RestDataSourceDefinition(); dataSourceDefinition.setType("foo bar"); dataSourceDefinition.set("hello", "world"...
ImmutableEdge implements Edge<V> { @Override public String toString() { return "ImmutableEdge [source=" + source + ", dest=" + dest + ", id=" + id + "]"; } ImmutableEdge(final V source, final V dest, final int id); static ImmutableEdge<V> construct(final V source, final V dest, final int id); @Override final V ge...
@Test public void testToString() { assertEquals("ImmutableEdge [source=1, dest=2, id=1]", edge.toString()); }
MersenneTwister extends java.util.Random implements Serializable, Cloneable { public double nextDouble() { return (((long) next(26) << 27) + next(27)) / (double) (1L << 53); } MersenneTwister(); MersenneTwister(long seed); MersenneTwister(int[] array); @Override Object clone(); synchronized boolean stateEquals(Mersen...
@Test public void testRun() { List<Double> values = new ArrayList<>(); for (int i = 0; i < 10_000; ++i) { values.add(rng.nextDouble()); } Assert.assertEquals(0.5, values.stream().mapToDouble(x -> (double) x).average().orElse(-1.0), 0.01); }
OntologyTerms { public static <O extends Ontology<?, ?>> void visitChildrenOf(TermId termId, O ontology, TermVisitor<O> termVisitor) { BreadthFirstSearch<TermId, ImmutableEdge<TermId>> bfs = new BreadthFirstSearch<>(); @SuppressWarnings("unchecked") DirectedGraph<TermId, ImmutableEdge<TermId>> graph = (DirectedGraph<Te...
@Test public void testVisitChildrenOf() { Set<TermId> children = new TreeSet<>(); OntologyTerms.visitChildrenOf(idRootVegetable, ontology, new TermVisitor<ImmutableOntology<VegetableTerm, VegetableTermRelation>>() { @Override public boolean visit(ImmutableOntology<VegetableTerm, VegetableTermRelation> ontology, TermId ...
OntologyTerms { public static <O extends Ontology<?, ?>> Set<TermId> childrenOf(TermId termId, O ontology) { Set<TermId> result = new HashSet<>(); visitChildrenOf(termId, ontology, new TermVisitor<O>() { @Override public boolean visit(O ontology, TermId termId) { result.add(termId); return true; } }); return result; } ...
@Test public void testChildrenOf() { assertEquals( "[ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000004], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000005], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000006], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0...
OntologyTerms { public static <O extends Ontology<?, ?>> void visitParentsOf(TermId termId, O ontology, TermVisitor<O> termVisitor) { BreadthFirstSearch<TermId, ImmutableEdge<TermId>> bfs = new BreadthFirstSearch<>(); @SuppressWarnings("unchecked") DirectedGraph<TermId, ImmutableEdge<TermId>> graph = (DirectedGraph<Ter...
@Test public void testVisitParentsOf() { Set<TermId> parents = new TreeSet<>(); OntologyTerms.visitParentsOf(idBlueCarrot, ontology, new TermVisitor<ImmutableOntology<VegetableTerm, VegetableTermRelation>>() { @Override public boolean visit(ImmutableOntology<VegetableTerm, VegetableTermRelation> ontology, TermId termId...
OntologyTerms { public static <O extends Ontology<?, ?>> Set<TermId> parentsOf(TermId termId, O ontology) { Set<TermId> result = new HashSet<>(); visitParentsOf(termId, ontology, new TermVisitor<O>() { @Override public boolean visit(O ontology, TermId termId) { result.add(termId); return true; } }); return result; } s...
@Test public void testParentsOf() { assertEquals( "[ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000004], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000007], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=0000001], ImmutableTermId [prefix=ImmutableTermPrefix [value=VO], id=00...
InformationContentComputation { public <LabelT> Map<TermId, Double> computeInformationContent(Map<TermId, ? extends Collection<LabelT>> termLabels) { LOGGER.info("Computing IC of {} terms using {} labels...", new Object[] {ontology.countAllTerms(), termLabels.values().stream().mapToInt(l -> l.size()).sum()}); final Ter...
@Test public void test() { Map<TermId, Collection<String>> termLabels = TermAnnotations.constructTermAnnotationToLabelsMap(ontology, recipeAnnotations); Map<TermId, Double> informationContent = computation.computeInformationContent(termLabels); assertEquals(7, informationContent.size()); assertEquals(0.0, informationCo...
SimilarityScoreSampling { public Map<Integer, ScoreDistribution> performSampling( Map<Integer, ? extends Collection<TermId>> labels) { Map<Integer, ScoreDistribution> result = new HashMap<>(); for (int numTerms = options.getMinNumTerms(); numTerms <= options .getMaxNumTerms(); ++numTerms) { result.put(numTerms, perform...
@Test public void test() { Map<String, Integer> recipeToId = new HashMap<>(); Map<Integer, Set<TermId>> labels = new HashMap<>(); int nextId = 1; for (VegetableRecipeAnnotation a : recipeAnnotations) { if (!recipeToId.containsKey(a.getLabel())) { recipeToId.put(a.getLabel(), nextId++); } final int recipeId = recipeToId...
ObjectScoreDistribution implements Serializable { public double estimatePValue(double score) { Entry<Double, Double> previous = null; for (Entry<Double, Double> entry : cumulativeFrequencies.entrySet()) { if (previous == null && score < entry.getKey()) { return 1.0; } if (previous != null && previous.getKey() <= score ...
@Test public void testEstimatePValue() { assertEquals(1.0, objDist.estimatePValue(0.0), 0.01); assertEquals(0.82, objDist.estimatePValue(0.2), 0.01); assertEquals(0.82, objDist.estimatePValue(0.4), 0.01); assertEquals(0.42, objDist.estimatePValue(0.6), 0.01); assertEquals(0.42, objDist.estimatePValue(0.8), 0.01); asser...
ScoreDistributions { public static ScoreDistribution merge(Collection<ScoreDistribution> distributions) { if (distributions.isEmpty()) { throw new CannotMergeScoreDistributions("Cannot merge zero ScoreDistributions objects."); } if (distributions.stream().map(d -> d.getNumTerms()).collect(Collectors.toSet()).size() != ...
@Test public void test() { ScoreDistribution result = ScoreDistributions.merge(dist1, dist2); assertEquals(2, result.getNumTerms()); assertEquals("[1, 2]", ImmutableSortedSet.copyOf(result.getObjectIds()).toString()); assertEquals(1, result.getObjectScoreDistribution(1).getObjectId()); assertEquals(2, result.getObjectS...
ScoreSamplingOptions implements Serializable, Cloneable { @Override public String toString() { return "ScoreSamplingOptions [numThreads=" + numThreads + ", minObjectId=" + minObjectId + ", maxObjectId=" + maxObjectId + ", minNumTerms=" + minNumTerms + ", maxNumTerms=" + maxNumTerms + ", numIterations=" + numIterations ...
@Test public void testDefaultConstruction() { samplingOptions = new ScoreSamplingOptions(); assertEquals( "ScoreSamplingOptions [numThreads=1, minObjectId=null, maxObjectId=null, minNumTerms=1, maxNumTerms=20, numIterations=100000, seed=42]", samplingOptions.toString()); } @Test public void testFullConstruction() { sam...
ImmutableEdge implements Edge<V> { @Override public final Object clone() { return new ImmutableEdge<V>(source, dest, id); } ImmutableEdge(final V source, final V dest, final int id); static ImmutableEdge<V> construct(final V source, final V dest, final int id); @Override final V getSource(); @Override final V get...
@Test @SuppressWarnings("unchecked") public void testClone() { ImmutableEdge<Integer> e2 = (ImmutableEdge<Integer>) edge.clone(); assertNotSame(edge, e2); assertEquals(edge, e2); assertEquals("ImmutableEdge [source=1, dest=2, id=1]", e2.toString()); }
TermIds { public static Set<TermId> augmentWithAncestors(ImmutableOntology<?, ?> ontology, Set<TermId> termIds, boolean includeRoot) { termIds.addAll(ontology.getAllAncestorTermIds(termIds, includeRoot)); return termIds; } static Set<TermId> augmentWithAncestors(ImmutableOntology<?, ?> ontology, Set<TermId> term...
@Test public void test() { Set<TermId> inputIds = Sets.newHashSet(id1); Set<TermId> outputIds = ImmutableSortedSet.copyOf(TermIds.augmentWithAncestors(ontology, inputIds, true)); assertEquals( "[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], ...
TermAnnotations { public static Map<TermId, Collection<String>> constructTermAnnotationToLabelsMap( Ontology<?, ?> ontology, Collection<? extends TermAnnotation> annotations) { final Map<TermId, Collection<String>> result = new HashMap<>(); for (TermAnnotation anno : annotations) { for (TermId termId : ontology.getAnce...
@Test public void testConstructTermAnnotationToLabelsMap() { Map<TermId, Collection<String>> map = ImmutableSortedMap .copyOf(TermAnnotations.constructTermAnnotationToLabelsMap(ontology, annotations)); assertEquals( "{ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001]=[two, one], ImmutableTermId [prefi...
TermAnnotations { public static Map<String, Collection<TermId>> constructTermLabelToAnnotationsMap( Ontology<?, ?> ontology, Collection<? extends TermAnnotation> annotations) { final Map<String, Collection<TermId>> result = new HashMap<>(); for (TermAnnotation anno : annotations) { for (TermId termId : ontology.getAnce...
@Test public void testConstructTermLabelToAnnotationsMap() { Map<String, Collection<TermId>> map = ImmutableSortedMap .copyOf(TermAnnotations.constructTermLabelToAnnotationsMap(ontology, annotations)); assertEquals( "{one=[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000002], ImmutableTermId [prefix=Immu...
ImmutableTermId implements TermId { @Override public int compareTo(TermId that) { return ComparisonChain.start().compare(this.getPrefix(), that.getPrefix()) .compare(this.getId(), that.getId()).result(); } ImmutableTermId(TermPrefix prefix, String id); static ImmutableTermId constructWithPrefix(String termIdString); @O...
@Test public void testComparable() { assertEquals(0, termId.compareTo(termId)); assertThat(termId.compareTo(termId2), lessThan(0)); assertThat(termId2.compareTo(termId), greaterThan(0)); }
ImmutableTermId implements TermId { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof TermId) { final TermId that = (TermId) obj; return this.prefix.equals(that.getPrefix()) && (this.id.equals(that.getId())); } else { return false; } } ImmutableTermId(TermPrefix pre...
@Test public void testEquals() { assertTrue(termId.equals(termId)); assertFalse(termId.equals(termId2)); }
ImmutableTermId implements TermId { @Override public String toString() { return "ImmutableTermId [prefix=" + prefix + ", id=" + id + "]"; } ImmutableTermId(TermPrefix prefix, String id); static ImmutableTermId constructWithPrefix(String termIdString); @Override int compareTo(TermId that); @Override TermPrefix getPrefix...
@Test public void testToString() { assertEquals("ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001]", termId.toString()); }
ImmutableTermPrefix implements TermPrefix { @Override public int compareTo(TermPrefix o) { if (this == o) { return 0; } else { return value.compareTo(o.getValue()); } } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Override int hashC...
@Test public void testComparable() { assertEquals(0, termPrefix.compareTo(termPrefix)); assertThat(termPrefix.compareTo(termPrefix2), greaterThan(0)); assertThat(termPrefix2.compareTo(termPrefix), lessThan(0)); }
ImmutableTermPrefix implements TermPrefix { @Override public String getValue() { return value; } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
@Test public void testQueryFunctions() { assertEquals("HP", termPrefix.getValue()); }
ImmutableTermPrefix implements TermPrefix { @Override public String toString() { return "ImmutableTermPrefix [value=" + value + "]"; } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Ob...
@Test public void testToString() { assertEquals("ImmutableTermPrefix [value=HP]", termPrefix.toString()); }
ImmutableEdge implements Edge<V> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } @SuppressWarnings("unchecked") ImmutableEdge<V> other = (ImmutableEdge<V>) obj; if (dest == null) { if (other.dest != ...
@Test @SuppressWarnings("unchecked") public void testEquals() { assertTrue(edge.equals(edge)); ImmutableEdge<Integer> e2 = (ImmutableEdge<Integer>) edge.clone(); assertTrue(edge.equals(e2)); ImmutableEdge<Integer> e3 = ImmutableEdge.construct(3, 2, 1); assertFalse(edge.equals(e3)); ImmutableEdge<Integer> e4 = Immutable...
SimpleFeatureVectorSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { return Sets.intersection(Sets.newHashSet(query), Sets.newHashSet(target)).size(); } @Override String getName(); @Override String getParameters(); @Override boolean isSymmetr...
@Test public void testComputeSimilarities() { assertEquals(1.0, similarity.computeScore( Lists.newArrayList(ImmutableTermId.constructWithPrefix("HP:0000008"), ImmutableTermId.constructWithPrefix("HP:0000009")), Lists.newArrayList(ImmutableTermId.constructWithPrefix("HP:0000008"))), 0.01); assertEquals(1.0, similarity.c...
JaccardSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); double intersectionS...
@Test public void testComputeSimilarities() { assertEquals(0.25, similarity.computeScore(Lists.newArrayList(idBeet), Lists.newArrayList(idCarrot)), 0.01); assertEquals(0.66, similarity.computeScore(Lists.newArrayList(idBlueCarrot), Lists.newArrayList(idCarrot)), 0.01); assertEquals(0.33, similarity.computeScore(Lists.n...
CosineSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); return Sets.intersection(te...
@Test public void testComputeSimilarities() { assertEquals(0.408, similarity.computeScore(Lists.newArrayList(idBeet), Lists.newArrayList(idCarrot)), 0.01); assertEquals(0.816, similarity.computeScore(Lists.newArrayList(idBlueCarrot), Lists.newArrayList(idCarrot)), 0.01); assertEquals(0.50, similarity.computeScore(Lists...
PrecomputingPairwiseResnikSimilarity implements PairwiseSimilarity, Serializable { @Override public double computeScore(TermId query, TermId target) { return precomputedScores.get(query, target); } PrecomputingPairwiseResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc, int numThrea...
@Test public void testComputeSimilarities() { assertEquals(0.0, similarity.computeScore(idBeet, idCarrot), 0.01); assertEquals(0.405, similarity.computeScore(idBlueCarrot, idCarrot), 0.01); assertEquals(0.0, similarity.computeScore(idPumpkin, idCarrot), 0.01); assertEquals(0.0, similarity.computeScore(idLeafVegetable, ...
TermOverlapSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); double overlap =...
@Test public void testComputeSimilarities() { assertEquals(0.5, similarity.computeScore(Lists.newArrayList(idBeet), Lists.newArrayList(idCarrot)), 0.01); assertEquals(1.0, similarity.computeScore(Lists.newArrayList(idBlueCarrot), Lists.newArrayList(idCarrot)), 0.01); assertEquals(0.5, similarity.computeScore(Lists.newA...
PairwiseResnikSimilarity implements PairwiseSimilarity { @Override public double computeScore(TermId query, TermId target) { return computeScoreImpl(query, target); } protected PairwiseResnikSimilarity(); PairwiseResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc); double computeScoreImpl(Te...
@Test public void testComputeSimilarities() { assertEquals(0.0, similarity.computeScore(idBeet, idCarrot), 0.01); assertEquals(0.405, similarity.computeScore(idBlueCarrot, idCarrot), 0.01); assertEquals(0.0, similarity.computeScore(idPumpkin, idCarrot), 0.01); assertEquals(0.0, similarity.computeScore(idLeafVegetable, ...
ResnikSimilarity extends AbstractCommonAncestorSimilarity<T, R> { @Override public String getName() { return "Resnik similarity"; } ResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc, boolean symmetric); ResnikSimilarity(PairwiseSimilarity pairwiseSimilarity, boolean symmetric); @Override Str...
@Test public void testQueries() { assertEquals("Resnik similarity", similarity.getName()); assertEquals(true, similarity.isSymmetric()); assertEquals("{symmetric: true}", similarity.getParameters()); }
HpoOboParser implements OntologyOboParser<HpoOntology> { @SuppressWarnings("unchecked") public HpoOntology parse() throws IOException { final OboImmutableOntologyLoader<HpoTerm, HpoTermRelation> loader = new OboImmutableOntologyLoader<>(oboFile, debug); final HpoOboFactory factory = new HpoOboFactory(); final Immutable...
@Test public void testParseHpoHead() throws IOException { final HpoOboParser parser = new HpoOboParser(hpoHeadFile, true); final HpoOntology ontology = parser.parse(); assertEquals( "ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001]=ImmutableVertexEdgeList [inEdges=[...
GoOboParser implements OntologyOboParser<GoOntology> { @SuppressWarnings("unchecked") public GoOntology parse() throws IOException { final OboImmutableOntologyLoader<GoTerm, GoTermRelation> loader = new OboImmutableOntologyLoader<>(oboFile, debug); final GoOboFactory factory = new GoOboFactory(); final ImmutableOntolog...
@Test public void testParseHpoHead() throws IOException { final GoOboParser parser = new GoOboParser(goHeadFile, true); final GoOntology ontology = parser.parse(); assertEquals( "ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=GO], id=0000000]=ImmutableVertexEdgeList [inEdges=[Immu...
UberphenoOboParser implements OntologyOboParser<UberphenoOntology> { @SuppressWarnings("unchecked") @Override public UberphenoOntology parse() throws IOException { final OboImmutableOntologyLoader<UberphenoTerm, UberphenoTermRelation> loader = new OboImmutableOntologyLoader<>(oboFile, debug); final UberphenoOboFactory ...
@Test public void testParseUberphenoHead() throws IOException { final UberphenoOboParser parser = new UberphenoOboParser(uberphenoHeadFile, true); final UberphenoOntology ontology = parser.parse(); assertEquals( "ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001]=Immu...
ImmutableDirectedGraph implements DirectedGraph<V, E> { public static <V extends Comparable<V>, E extends ImmutableEdge<V>> Builder<V, E> builder(final Edge.Factory<V, E> edgeFactory) { return new Builder<V, E>(edgeFactory); } private ImmutableDirectedGraph(final Collection<V> vertices, final Collection<E> edges...
@Test public void testBuilder() { Builder<Integer, ImmutableEdge<Integer>> builder = ImmutableDirectedGraph.builder(new ImmutableEdge.Factory<Integer>()); for (int i = 1; i <= 5; ++i) { builder.addVertex(i); } for (int i = 2; i <= 4; ++i) { builder.addEdge(1, i); builder.addEdge(i, 5); } ImmutableDirectedGraph<Integer,...
MpoOboParser implements OntologyOboParser<MpoOntology> { @SuppressWarnings("unchecked") public MpoOntology parse() throws IOException { final OboImmutableOntologyLoader<MpoTerm, MpoTermRelation> loader = new OboImmutableOntologyLoader<>(oboFile, debug); final MpoOboFactory factory = new MpoOboFactory(); final Immutable...
@Test public void testParseHpoHead() throws IOException { final MpoOboParser parser = new MpoOboParser(mpoHeadFile, true); final MpoOntology ontology = parser.parse(); assertEquals( "ImmutableDirectedGraph [edgeLists={ImmutableTermId [prefix=ImmutableTermPrefix [value=MP], id=0000001]=ImmutableVertexEdgeList [inEdges=[...
OboParser { public OboFile parseString(String oboString) { final HelperListener helper = new HelperListener(); parseString(oboString, helper); return new OboFile(helper.getHeader(), helper.getStanzas()); } OboParser(); OboParser(boolean debug); OboFile parseFile(File file); void parseFile(File file, OboParseResultList...
@Test public void testAllInOneParsing() { final OboFile oboFile = parser.parseString(MINI_OBO); assertEquals("OBOFile [header=Header [entries=[StanzaEntryFormatVersion [value=1.2, " + "getType()=FORMAT_VERSION, getTrailingModifier()=null, getComment()=null]], " + "entryByType={FORMAT_VERSION=[StanzaEntryFormatVersion [...
ImmutableDirectedGraph implements DirectedGraph<V, E> { @Override public String toString() { return "ImmutableDirectedGraph [edgeLists=" + ImmutableSortedMap.copyOf(edgeLists) + ", edgeCount=" + edgeCount + "]"; } private ImmutableDirectedGraph(final Collection<V> vertices, final Collection<E> edges); static Bui...
@Test public void testToString() { assertEquals("ImmutableDirectedGraph [edgeLists={1=ImmutableVertexEdgeList " + "[inEdges=[], outEdges=[ImmutableEdge [source=1, dest=2, id=1], " + "ImmutableEdge [source=1, dest=3, id=2], ImmutableEdge [source=1, dest=4, id=3]]], " + "2=ImmutableVertexEdgeList [inEdges=[ImmutableEdge ...
ImmutableDirectedGraph implements DirectedGraph<V, E> { @Override public Iterator<E> outEdgeIterator(V v) { return edgeLists.get(v).getOutEdges().iterator(); } private ImmutableDirectedGraph(final Collection<V> vertices, final Collection<E> edges); static Builder<V, E> builder(final Edge.Factory<V, E> edgeFactor...
@Test public void testOutEdgeIterator() { Iterator<ImmutableEdge<Integer>> it = graph.outEdgeIterator(1); List<ImmutableEdge<Integer>> edges = new ArrayList<>(); while (it.hasNext()) { edges.add(it.next()); } assertEquals("[ImmutableEdge [source=1, dest=2, id=1], ImmutableEdge [source=1, dest=3, id=2], " + "ImmutableEd...
ImmutableDirectedGraph implements DirectedGraph<V, E> { @Override public Iterator<E> inEdgeIterator(V v) { return edgeLists.get(v).getInEdges().iterator(); } private ImmutableDirectedGraph(final Collection<V> vertices, final Collection<E> edges); static Builder<V, E> builder(final Edge.Factory<V, E> edgeFactory)...
@Test public void testInEdgeIterator() { Iterator<ImmutableEdge<Integer>> it = graph.inEdgeIterator(5); List<ImmutableEdge<Integer>> edges = new ArrayList<>(); while (it.hasNext()) { edges.add(it.next()); } assertEquals("[ImmutableEdge [source=2, dest=5, id=4], ImmutableEdge [source=3, dest=5, id=5], " + "ImmutableEdge...
ImmutableDirectedGraph implements DirectedGraph<V, E> { @Override public Iterator<V> viaOutEdgeIterator(V v) { final Iterator<? extends Edge<V>> iter = outEdgeIterator(v); return new Iterator<V>() { @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().getDes...
@Test public void testViaOutEdgeIterator() { Iterator<Integer> it = graph.viaOutEdgeIterator(1); List<Integer> vertices = new ArrayList<>(); while (it.hasNext()) { vertices.add(it.next()); } assertEquals("[2, 3, 4]", vertices.toString()); }
ImmutableDirectedGraph implements DirectedGraph<V, E> { @Override public Iterator<V> viaInEdgeIterator(V v) { final Iterator<? extends Edge<V>> iter = inEdgeIterator(v); return new Iterator<V>() { @Override public boolean hasNext() { return iter.hasNext(); } @Override public V next() { return iter.next().getSourc...
@Test public void testViaInEdgeIterator() { Iterator<Integer> it = graph.viaInEdgeIterator(5); List<Integer> vertices = new ArrayList<>(); while (it.hasNext()) { vertices.add(it.next()); } assertEquals("[2, 3, 4]", vertices.toString()); }
ImmutableDirectedGraph implements DirectedGraph<V, E> { @SuppressWarnings("unchecked") @Override public DirectedGraph<V, E> subGraph(Collection<V> vertices) { Set<V> argVertexSet = ImmutableSet.copyOf(vertices); Set<V> vertexSubset = new HashSet<V>(); Iterator<V> vertexIt = vertexIterator(); while (vertexIt.hasNe...
@Test public void testSubGraph() { DirectedGraph<Integer, ImmutableEdge<Integer>> subGraph = graph.subGraph(ImmutableList.of(1, 2, 5)); assertEquals("ImmutableDirectedGraph [edgeLists={1=ImmutableVertexEdgeList [inEdges=[], " + "outEdges=[ImmutableEdge [source=1, dest=2, id=1]]], " + "2=ImmutableVertexEdgeList [inEdges...
BronWatchList { public boolean isWatched(Entiteit entity) { return list.containsKey(Hibernate.getClass(entity)); } boolean isWatched(Entiteit entity); boolean isWatched(Entiteit entiteit, String property); static boolean isSleutelWaarde(Entiteit entiteit, String expression); static boolean isSleutelWaarde(IdObject ent...
@Test public void controleerDeelnemerProperties() { Deelnemer deelnemer = new Deelnemer(); assertTrue(watches.isWatched(deelnemer)); assertTrue(watches.isWatched(deelnemer, "onderwijsnummer")); assertFalse(watches.isWatched(deelnemer, "id")); } @Test public void controleerPersoonProperties() { Persoon persoon = new Per...
StringUtil { public static String puntSeperated(String sentence) { List<String> adapted = new ArrayList<String>(); for (int i = 0; i < sentence.length(); i++) { char c = sentence.charAt(i); if (c != '.') { boolean done = false; for (String samengesteld : SAMENGESTELDE_LETTERS) { if (sentence.substring(i).toUpperCase()....
@Test public void puntSeparated() { assertEquals("A.", StringUtil.puntSeperated("a")); assertEquals("A.B.C.", StringUtil.puntSeperated("abc")); assertEquals("", StringUtil.puntSeperated("")); assertEquals("IJ.K.", StringUtil.puntSeperated("IJK")); assertEquals("K.IJ.", StringUtil.puntSeperated("kij")); assertEquals("K....
StringUtil { public static int countOccurances(String org, char character) { if (org == null) return 0; int count = 0; int index = 0; while (index >= 0) { index = org.indexOf(character, index); if (index >= 0) { count++; index++; } } return count; } private StringUtil(); static boolean checkMatchesRegExp(String parame...
@Test public void countOccurances() { assertEquals(0, StringUtil.countOccurances(null, '.')); assertEquals(0, StringUtil.countOccurances("", '.')); assertEquals(0, StringUtil.countOccurances(" ", '.')); assertEquals(0, StringUtil.countOccurances("abcdefgh", '.')); assertEquals(1, StringUtil.countOccurances(".", '.')); ...
StringUtil { public static <T> String toString(Collection<T> list, String token, String defaultString) { return toString(list, defaultString, new DefaultStringConverter<T>(token)); } private StringUtil(); static boolean checkMatchesRegExp(String parameter, String value, String regexp); @Deprecated() static String stri...
@Test public void toStringTest() { assertNull("_", StringUtil.toString(null, "-", (String) null)); assertEquals("_", StringUtil.toString(null, "-", "_")); assertEquals("_", StringUtil.toString(JavaUtil.asList(), "-", "_")); assertEquals("1", StringUtil.toString(JavaUtil.asList(1), "-", "_")); assertEquals("1-2", String...
StringUtil { public static String convertCamelCase(String camelCase) { if (camelCase == null) return null; boolean containsEduArte = camelCase.contains("EduArte"); boolean containsRedSpider = camelCase.contains("RedSpider"); StringBuilder builder = new StringBuilder(camelCase.length() + 10); builder.append(camelCase.ch...
@Test public void convertCamelCase() { String[] camels = new String[] {"EduArteDeelnemerMutatieLogVerwerker", "EenEduArteDeelnemerMutatieLogVerwerker", "RedSpiderDeelnemerWijzigingenVerwerker", "TheQuickLittleBrownFox", "HTTP", "HTTPRequest", "STATIC_CONSTANT", null}; String[] converted = new String[] {"EduArte deelnem...
StringUtil { public static boolean checkMatchesRegExp(String parameter, String value, String regexp) { Asserts.assertNotNull(parameter, value); Asserts.assertNotNull("regexp", regexp); Pattern pattern = Pattern.compile(regexp); String trimmedValue = value.trim(); Matcher matcher = pattern.matcher(trimmedValue.subSequen...
@Test public void checkMatchesRegExp() { assertTrue(StringUtil.checkMatchesRegExp("test", "abc", ".*")); assertTrue(StringUtil.checkMatchesRegExp("test", "abc", "\\w*")); assertTrue(StringUtil.checkMatchesRegExp("test", "abc", "\\w*")); assertFalse(StringUtil.checkMatchesRegExp("test", "a$bc", "\\w*")); assertTrue(Stri...
StringUtil { public static String emptyOrStringValue(Object value) { if (value == null) return ""; return String.valueOf(value); } private StringUtil(); static boolean checkMatchesRegExp(String parameter, String value, String regexp); @Deprecated() static String stripHighAscii(String tekst); static Integer getFirstNum...
@Test public void emptyOrStringValue() { assertEquals("", StringUtil.emptyOrStringValue(null)); assertEquals("1", StringUtil.emptyOrStringValue(1)); }
StringUtil { public static String nullOrStringValue(Object value) { if (value == null) return null; return String.valueOf(value); } private StringUtil(); static boolean checkMatchesRegExp(String parameter, String value, String regexp); @Deprecated() static String stripHighAscii(String tekst); static Integer getFirstNu...
@Test public void nullOrStringValue() { assertNull(StringUtil.nullOrStringValue(null)); assertEquals("1", StringUtil.nullOrStringValue(1)); }
StringUtil { public static boolean isIpAdres(String string) { Pattern pattern = Pattern.compile(IPADRES_PATTERN, Pattern.CASE_INSENSITIVE); return !isEmpty(string) && pattern.matcher(string).matches(); } private StringUtil(); static boolean checkMatchesRegExp(String parameter, String value, String regexp); @Deprecated...
@Test public void checkIsIpAdres() { assertTrue(StringUtil.isIpAdres("1.1.1.1")); assertTrue(StringUtil.isIpAdres("192.168.1.1")); assertTrue(StringUtil.isIpAdres("255.255.255.255")); assertFalse(StringUtil.isIpAdres("192.168.1.x")); assertFalse(StringUtil.isIpAdres("192.168.1.")); assertFalse(StringUtil.isIpAdres("192...
TimeUtil { public Date asDate(Date date) { if (date == null) return null; return asDate(date.getTime()); } TimeUtil(); TimeUtil(Calendar calendar); Date asDate(Date date); Date asDate(long date); Date asDate(int year, int month, int day); Date isoStringAsDate(String isoDateString); Date isoStringAsDateTime(String isoD...
@Test public void testAsDate() { Calendar calendar = Calendar.getInstance(); Date calibration = setAndTestDate(calendar, 4679, Calendar.JUNE, 4); TimeUtil util = new TimeUtil(); Date result = util.asDate(calibration); assertNotNull(result); calendar.setTime(result); testDate(calendar, 4679, Calendar.JUNE, 4); calibrati...
TimeUtil { public Date asTime(Date date) { if (date == null) return null; return asTime(date.getTime()); } TimeUtil(); TimeUtil(Calendar calendar); Date asDate(Date date); Date asDate(long date); Date asDate(int year, int month, int day); Date isoStringAsDate(String isoDateString); Date isoStringAsDateTime(String isoD...
@Test public void testAsTime() { Calendar calendar = Calendar.getInstance(); Date calibration = setAndTestTime(calendar, 16, 20, 55); TimeUtil util = new TimeUtil(); Date result = util.asTime(calibration); assertNotNull(result); calendar.setTime(result); testTime(calendar, 16, 20, 55); }
BronEduArteModel { public boolean isInBronScope(Adres adres) { if (adres == null) return false; List<PersoonAdres> persoonAdressen = adres.getPersoonAdressen(); if (persoonAdressen == null || persoonAdressen.isEmpty()) { return false; } for (PersoonAdres persoonAdres : persoonAdressen) { if (isInBronScope(persoonAdres....
@Test public void deelnemerMetVoorlopigeVerbintenisNietInScope() { Deelnemer deelnemer = maakDeelnemerMetVerbintenis(Voorlopig); assertFalse(model.isInBronScope(deelnemer)); } @Test public void deelnemerMetVolledigeVerbintenisInScope() { Deelnemer deelnemer = maakDeelnemerMetVerbintenis(Volledig); assertTrue(model.isIn...
TimeUtil { public Date asDateTime(Date date) { if (date == null) return null; return asDateTime(date.getTime()); } TimeUtil(); TimeUtil(Calendar calendar); Date asDate(Date date); Date asDate(long date); Date asDate(int year, int month, int day); Date isoStringAsDate(String isoDateString); Date isoStringAsDateTime(Str...
@Test public void testAsDateTime() { Calendar calendar = Calendar.getInstance(); Date calibration = setAndTestDate(calendar, 4679, Calendar.JUNE, 4); calibration = setAndTestTime(calendar, 16, 20, 55); TimeUtil util = new TimeUtil(); Date result = util.asDateTime(calibration); assertNotNull(result); calendar.setTime(re...
TimeUtil { public int getWorkDays(Date date, int days) { int workDays = days; if (workDays < 0) Math.abs(workDays); workDays = workDays - getWeekendDays(date, days); return workDays; } TimeUtil(); TimeUtil(Calendar calendar); Date asDate(Date date); Date asDate(long date); Date asDate(int year, int month, int day); Da...
@Test public void testGetWorkDays() { TimeUtil util = new TimeUtil(); Calendar calendar = Calendar.getInstance(); assertEquals(util.getWorkDays(setAndTestDate(calendar, 2006, Calendar.JULY, 25), 3), 3); assertEquals(util.getWorkDays(setAndTestDate(calendar, 2006, Calendar.JULY, 25), 5), 3); assertEquals(util.getWorkDay...
TimeUtil { public int getWeekendDays(Date date, int days) { Date tempDate = date; int tempDays = days; boolean future = days >= 0; if (!future) { tempDate = addDays(tempDate, tempDays - 1); tempDays = Math.abs(tempDays); } int fixedSunday = Calendar.SUNDAY; int dateDay = getDayOfWeek(tempDate); if (Calendar.SUNDAY < Ca...
@Test public void testGetWeekendDays() { TimeUtil util = new TimeUtil(); Calendar calendar = Calendar.getInstance(); assertEquals(util.getWeekendDays(setAndTestDate(calendar, 2006, Calendar.JULY, 25), 1), 0); assertEquals(util.getWeekendDays(setAndTestDate(calendar, 2006, Calendar.JANUARY, 1), 365), 104); assertEquals(...
ResourceUtil { public static void flush(Object objectToFlush) { if (objectToFlush instanceof Flushable) { Flushable flushable = (Flushable) objectToFlush; try { flushable.flush(); } catch (IOException e) { log.error(e.toString(), e); throw new RuntimeException(e); } } } private ResourceUtil(); static void closeQuietly...
@Test(expected = RuntimeException.class) public void flushWithException() { ResourceUtil.flush(new Flushable() { @Override public void flush() throws IOException { throw new IOException("Een verwachte exceptie"); } }); } @Test public void flushWithNull() { ResourceUtil.flush(null); } @Test public void flush() { Resourc...
Utf8BufferedWriter extends BufferedWriter { public void writeByteOrderMark() throws IOException { write(new String(BOM, "UTF-8")); } Utf8BufferedWriter(File file); Utf8BufferedWriter(File file, int size); void writeByteOrderMark(); static byte[] BOM; }
@Test public void testWriteByteOrderMark() throws IOException { String filename = "target/Utf8BufferedWriterTest_bom.txt"; String text = "UTF-8 Test met byte order mark"; writeString(createWriter(filename), true, text); FileInputStream in = new FileInputStream(filename); byte[] actual = new byte[3]; in.read(actual, 0, ...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) { Set<Integer> result = new HashSet<Integer>(); boolean shouldReturnNull = true; ...
@Test public void singleFindDirtyReturnsNull() { Interceptor interceptor = mock(Interceptor.class); when(interceptor.findDirty(null, null, null, null, null, null)).thenReturn(null); CompoundHibernateInterceptor compound = new CompoundHibernateInterceptor(interceptor); int[] dirty = compound.findDirty(null, null, null, ...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void afterTransactionBegin(Transaction tx) { for (Interceptor interceptor : interceptors) { interceptor.afterTransactionBegin(tx); } } CompoundHibernateInterceptor(); CompoundHibernateInterceptor(Interceptor... in...
@Test public void afterTransactionCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.afterTransactionBegin(null); verify(interceptor1).afterTran...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void afterTransactionCompletion(Transaction tx) { for (Interceptor interceptor : interceptors) { interceptor.afterTransactionCompletion(tx); } } CompoundHibernateInterceptor(); CompoundHibernateInterceptor(Interce...
@Test public void afterTransactionCompletionCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.afterTransactionCompletion(null); verify(intercep...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void beforeTransactionCompletion(Transaction tx) { for (Interceptor interceptor : interceptors) { interceptor.beforeTransactionCompletion(tx); } } CompoundHibernateInterceptor(); CompoundHibernateInterceptor(Inter...
@Test public void beforeTransactionCompletionCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.beforeTransactionCompletion(null); verify(interc...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public Object getEntity(String entityName, Serializable id) throws CallbackException { for (Interceptor interceptor : interceptors) { Object tmp = interceptor.getEntity(entityName, id); if (tmp != null) { return tmp; } } ...
@Test public void getEntityFallsThrough() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor1.getEntity(null, null)).thenReturn(null); when(interceptor2.getEntity(null, null)).thenReturn(null); Interceptor compound = new CompoundHibernateIntercepto...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public String getEntityName(Object object) throws CallbackException { for (Interceptor interceptor : interceptors) { String name = interceptor.getEntityName(object); if (name != null) { return name; } } return null; } Com...
@Test public void getEntityNameFallsThrough() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor1.getEntityName(null)).thenReturn(null); when(interceptor2.getEntityName(null)).thenReturn(null); Interceptor compound = new CompoundHibernateIntercepto...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException { for (Interceptor interceptor : interceptors) { Object entity = interceptor.instantiate(entityName, entityMode...
@Test public void instantiateFallsThrough() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor1.instantiate(null, null, null)).thenReturn(null); when(interceptor2.instantiate(null, null, null)).thenReturn(null); Interceptor compound = new CompoundH...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public Boolean isTransient(Object entity) { Boolean isTransient = null; for (Interceptor interceptor : interceptors) { isTransient = interceptor.isTransient(entity); if (isTransient != null) { return isTransient; } } retu...
@Test public void isTransientFallsThrough() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor1.isTransient(null)).thenReturn(null); when(interceptor2.isTransient(null)).thenReturn(null); Interceptor compound = new CompoundHibernateInterceptor(inte...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.onCollectionRecreate(collection, key); } } CompoundHibernateInter...
@Test public void onCollectionRecreateCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.onCollectionRecreate(null, null); verify(interceptor1)....
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void onCollectionRemove(Object collection, Serializable key) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.onCollectionRemove(collection, key); } } CompoundHibernateIntercept...
@Test public void onCollectionRemoveCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.onCollectionRemove(null, null); verify(interceptor1).onCo...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.onCollectionUpdate(collection, key); } } CompoundHibernateIntercept...
@Test public void onCollectionUpdateCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.onCollectionUpdate(null, null); verify(interceptor1).onCo...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.onDelete(entity, id, state, ...
@Test public void onDeleteCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.onDelete(null, null, null, null, null); verify(interceptor1).onDele...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException { boolean entityModified = false; for (Interceptor ...
@Test public void onFlushDirtyCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor1.onFlushDirty(null, null, null, null, null, null)).thenReturn(false); when(interceptor2.onFlushDirty(null, null, null, null, null, null)).th...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { boolean entityModified = false; for (Interceptor interceptor : interceptors) { entityM...
@Test public void onLoadCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); when(interceptor1.onLoad(null, null, null, null, null)).thenReturn(true); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor2.onLoad(null, null, null, null, null)).thenReturn(true); Interceptor com...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public String onPrepareStatement(String sql) { String result = sql; for (Interceptor interceptor : interceptors) { result = interceptor.onPrepareStatement(result); } return result; } CompoundHibernateInterceptor(); Compo...
@Test public void onPrepareStatementCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); String sql0 = "select * from dual"; String sql1 = "select * from dual1"; String sql2 = "select * from dual12"; when(interceptor1.onPrepareStatement(sql...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @Override public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { boolean entityModified = false; for (Interceptor interceptor : interceptors) { entityM...
@Test public void onSaveRecordsChangeAndCallsEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); when(interceptor1.onSave(null, null, null, null, null)).thenReturn(true); Interceptor interceptor2 = mock(Interceptor.class); when(interceptor2.onSave(null, null, null, null, null)).thenReturn(false); In...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @SuppressWarnings("unchecked") @Override public void postFlush(Iterator entities) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.postFlush(entities); } } CompoundHibernateInterceptor(); Compo...
@Test public void postFlushCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.postFlush(null); verify(interceptor1).postFlush(null); verify(inte...
CompoundHibernateInterceptor extends EmptyInterceptor implements Iterable<Interceptor> { @SuppressWarnings("unchecked") @Override public void preFlush(Iterator entities) throws CallbackException { for (Interceptor interceptor : interceptors) { interceptor.preFlush(entities); } } CompoundHibernateInterceptor(); Compoun...
@Test public void preFlushCalledForEachInterceptor() { Interceptor interceptor1 = mock(Interceptor.class); Interceptor interceptor2 = mock(Interceptor.class); Interceptor compound = new CompoundHibernateInterceptor(interceptor1, interceptor2); compound.preFlush(null); verify(interceptor1).preFlush(null); verify(interce...
InterceptingSessionFactory implements SessionFactory, InterceptorFactoryAware, HibernateSessionFactoryAware { public Session openSession() throws HibernateException { if (!interceptorFactories.isEmpty()) { return interceptedSession(null); } return sessionFactory.openSession(); } InterceptingSessionFactory(SessionFact...
@Test(expected = UnsupportedOperationException.class) public void openSessionWithInterceptorFails() { SessionFactory mockSessionFactory = mock(SessionFactory.class); Interceptor mockInterceptor = mock(Interceptor.class); InterceptingSessionFactory factory = new InterceptingSessionFactory(mockSessionFactory); factory.op...
BronEduArteModel { public Integer getHuisnummer(Deelnemer deelnemer) { if (!woontInNederland(deelnemer)) { return null; } return getHuisnummer(getWoonadres(deelnemer)); } Collection<Verbintenis> getVerbintenissen(Object entity); boolean isInBronScope(Adres adres); boolean isInBronScope(Persoon persoon); boolean isInBr...
@Test public void huisnummer9() { Deelnemer deelnemer = createDeelnemerMetPersoon(); Adres adres = deelnemer.getPersoon().getFysiekAdres().getAdres(); adres.setHuisnummer("9"); assertThat(model.getHuisnummer(deelnemer), is(9)); }
BronEduArteModel { public String getHuisnummerToevoeging(Deelnemer deelnemer) { if (!woontInNederland(deelnemer)) { return null; } String toevoeging = getWoonadres(deelnemer).getHuisnummerToevoeging(); if (StringUtil.isEmpty(toevoeging)) { return null; } return toevoeging.trim(); } Collection<Verbintenis> getVerbinten...
@Test public void huisnummerToevoeging9() { Deelnemer deelnemer = createDeelnemerMetPersoon(); Adres adres = deelnemer.getPersoon().getFysiekAdres().getAdres(); adres.setHuisnummer("9"); assertThat(model.getHuisnummerToevoeging(deelnemer), nullValue()); }
BronStateChange implements Serializable { @Override public String toString() { return entity.getClass().getSimpleName() + "." + propertyName + ": " + toString(previousValue) + " -> " + toString(currentValue); } BronStateChange(IdObject entity, String propertyName, Object previousValue, Object currentValue); boolean ...
@Test public void nieuweWaarde() { BronStateChange change = new BronStateChange(new Deelnemer(), "naam", null, "Alexander"); assertThat(change.toString(), is("Deelnemer.naam: -> Alexander")); } @Test public void datumWaarde() { Persoon persoon = new Persoon(); persoon.setId(12345L); BronStateChange change = new BronSta...
IntakeWizardModel implements IModel<IntakeWizardModel> { public Date getRegistratieDatum() { return registratieDatum; } IntakeWizardModel(); IntakeWizardModel(Medewerker medewerker); IntakeWizardModel(Deelnemer deelnemer, Medewerker medewerker); Intakegesprek createDefaultIntakegesprek(Verbintenis verbintenis); void ...
@Test public void registratieDatumIsSysteemDatum() { Date date = TimeUtil.getInstance().currentDate(); IntakeWizardModel model = new IntakeWizardModel(); Assert.assertEquals(date, model.getRegistratieDatum()); }
IntakeWizardModel implements IModel<IntakeWizardModel> { public Deelnemer getDeelnemer() { return deelnemerModel.getObject(); } IntakeWizardModel(); IntakeWizardModel(Medewerker medewerker); IntakeWizardModel(Deelnemer deelnemer, Medewerker medewerker); Intakegesprek createDefaultIntakegesprek(Verbintenis verbintenis...
@Test public void woonAdresIsPostAdresStandaardGezet() { IntakeWizardModel model = new IntakeWizardModel(); Assert.assertEquals(1, model.getDeelnemer().getPersoon().getFysiekAdressen().size()); Assert.assertEquals(1, model.getDeelnemer().getPersoon().getPostAdressen().size()); }
BeginEinddatumUtil { public static <T extends IBeginEinddatumEntiteit> List<T> getElementenOpPeildatum( List<T> lijst, Date peildatum) { List<T> resultaat = new ArrayList<T>(); for (T element : lijst) { if (element.isActief(peildatum)) { resultaat.add(element); } } return resultaat; } static boolean isActief(IBeginEin...
@Test public void filterLegeLijst() { List<PersoonAdres> lijst = new ArrayList<PersoonAdres>(); Assert.assertEquals(Collections.emptyList(), getElementenOpPeildatum(lijst, vandaag)); } @Test public void filterNaarLeegResultaat() { List<PersoonAdres> lijst = new ArrayList<PersoonAdres>(); adres.setBegindatum(morgen); li...
Token extends InstellingEntiteit { public String getSerienummer() { return serienummer; } Token(String serienummer, String applicatie, String blob); protected Token(); boolean verifieerPassword(String password); @SuppressWarnings("hiding") void geefUit(Account gebruiker); void neemIn(); void meldDefect(); void reparee...
@Test public void applicatienaamWordtVerwijderdVanSerienummer() { assertThat(token.getSerienummer(), is("123456789")); } @Test public void serienummerZonderapplicatienaamBlijftSerienummer() { assertThat(token.getSerienummer(), is("123456789")); }
Token extends InstellingEntiteit { public TokenStatus getStatus() { return status; } Token(String serienummer, String applicatie, String blob); protected Token(); boolean verifieerPassword(String password); @SuppressWarnings("hiding") void geefUit(Account gebruiker); void neemIn(); void meldDefect(); void repareer(); ...
@Test public void standaardStatusIsBeschikbaar() { assertThat(token.getStatus(), is(Beschikbaar)); }
Adres extends LandelijkOfInstellingEntiteit { public static String[] parseHuisnummerToevoeging(String text) { Pattern pattern = Pattern.compile("([0-9]+)(.*)"); Matcher matcher = pattern.matcher(text); if (!matcher.find()) { return StringUtils.stripAll(new String[] {text, ""}); } else { return StringUtils.stripAll(new ...
@Test public void testParseHuisnummer() { assertThat(Adres.parseHuisnummerToevoeging("100"), is(new String[] {"100", ""})); assertThat(Adres.parseHuisnummerToevoeging("100A"), is(new String[] {"100", "A"})); assertThat(Adres.parseHuisnummerToevoeging("100 A"), is(new String[] {"100", "A"})); assertThat(Adres.parseHuisn...
BronWatchList { public static boolean isSleutelWaarde(Entiteit entiteit, String expression) { Class< ? > key = Hibernate.getClass(entiteit); HashMap<String, Property> properties = list.get(key); if (properties != null && properties.containsKey(expression)) { Property property = properties.get(expression); return proper...
@Test public void isSleutelgegeven() { assertTrue(BronWatchList.isSleutelWaarde(new Persoon(), "bsn")); assertTrue(BronWatchList.isSleutelWaarde(new Deelnemer(), "onderwijsnummer")); assertFalse(BronWatchList.isSleutelWaarde(new Deelnemer(), "indicatieGehandicapt")); assertFalse(BronWatchList.isSleutelWaarde(new Deelne...
Brin extends ExterneOrganisatie { public Brin() { } Brin(); Brin(String brincode); @Exportable String getCode(); void setCode(String brincode); static boolean testBrincode(String brincode); @Override String toString(); void setOnderwijssector(Onderwijssector onderwijssector); Onderwijssector getOnderwijssector(); @Exp...
@Test public void testBrin() { assertThat(Brin.testBrincode("00AA"), is(true)); assertThat(Brin.testBrincode("00AA1"), is(true)); assertThat(Brin.testBrincode("00AA01"), is(true)); assertThat(Brin.testBrincode("0011"), is(true)); assertThat(Brin.testBrincode("00110"), is(true)); assertThat(Brin.testBrincode("001101"), ...
Brin extends ExterneOrganisatie { @Exportable public Integer getVestigingsVolgnummer() { String brincode = getCode(); if (brincode != null) { Matcher matcher = BRIN_REGEXP.matcher(brincode); if (!matcher.matches()) { Asserts.fail(brincode + " is geen geldige BRIN code"); } String volgnummer = matcher.group(2); if (volg...
@Test public void vestigingVolgnummer() { assertThat(new Brin("00AA1").getVestigingsVolgnummer(), is(1)); assertThat(new Brin("00AA01").getVestigingsVolgnummer(), is(1)); assertThat(new Brin("00AA09").getVestigingsVolgnummer(), is(9)); assertNull(new Brin("00AA").getVestigingsVolgnummer()); }
Schooljaar implements IBeginEinddatumEntiteit, Comparable<Schooljaar>, Serializable { public static Schooljaar valueOf(Date datum) { int startJaar = bepaalStartJaarVanSchooljaarActiefOpDatum(datum); return valueOf(startJaar); } private Schooljaar(int jaar); private Schooljaar(Date datum); int getStartJaar(); int ge...
@Test public void valueOfDate2008IsSJ_2008_2009() { Date date = TimeUtil.getInstance().asDate(2008, 11, 20); assertThat(Schooljaar.valueOf(date), is(Schooljaar.valueOf(2008))); }
Schooljaar implements IBeginEinddatumEntiteit, Comparable<Schooljaar>, Serializable { public boolean isAfgelopen() { Date current = TimeUtil.getInstance().currentDate(); return current.after(getEinddatum()); } private Schooljaar(int jaar); private Schooljaar(Date datum); int getStartJaar(); int getEindJaar(); @Over...
@Test public void isAfgelopen() { assertTrue(Schooljaar.valueOf(1990).isAfgelopen()); }