@Test public void testIsQueryableByPrimitiveRelationsWithTwoPrimitiveEntities() throws Exception { for (int j=0; j<5; j++) { resetSimpleSocialNetworkAndUpdateInitialState(); simpleSocialNetwork.users.add(user1); simpleSocialNetwork.users.add(user2); boolean user2_interfere_user1; if (j<2) { user2_interfere_user1 = true; if (j==0) user1.friends.add(user2); user1.hobbies.add("biking"); user2.hobbies.add("biking"); } else { user2_interfere_user1 = false; if (j==2) user1.hobbies.add("biking"); else if (j==3) { user2.hobbies.add("biking"); } else { assert j==4; user1.age++; } } State initialState = createStateFromCurrentSimpleSocialNetwork(); for (int usersInArgNum = 0; usersInArgNum <= 2; usersInArgNum++) { NonPrimitiveArgument emptyArg = new NonPrimitiveArgument(); SafeSet<String> usersInArg = new SafeHashSet<>(); if (usersInArgNum>0) usersInArg.add(initialState.getEntityId(user1)); if (usersInArgNum>1) usersInArg.add(initialState.getEntityId(user2)); NonPrimitiveArgument otherArg = new NonPrimitiveArgument(usersInArg); for (int emptyArgInd=0; emptyArgInd<2; emptyArgInd++) { MethodId method = new MethodId(User.class, "setAgeInTwoCollections", Collection.class, Integer.TYPE, Collection.class, Integer.TYPE); NonPrimitiveArgument nonPrimitiveArg0 = emptyArgInd == 0 ? emptyArg : otherArg; NonPrimitiveArgument nonPrimitiveArg1 = emptyArgInd == 1 ? emptyArg : otherArg; MethodCall fc = new MethodCall(method, initialState.getEntityId(user1), nonPrimitiveArg0, new PrimitiveArgument(3), nonPrimitiveArg1, new PrimitiveArgument(3)); boolean expectedRes = usersInArgNum==0 || usersInArgNum==2 || !user2_interfere_user1; assertEquals(expectedRes, generateHit(initialState,fc).isQueryableByPrimitiveRelations()); } } } }
public boolean isQueryableByPrimitiveRelations() { Collection<KBTriple> primitiveTriples = initialState.getGraphKb().getTriples().stream() .filter(triple -> triple.secondEntity instanceof PrimitiveEntity) .collect(Collectors.toList()); Set<String> idsOfNonPrimitiveEntitiesInPrimitiveRelations = primitiveTriples.stream() .map(triple -> initialState.getEntityId(triple.firstEntity)) .collect(Collectors.toSet()); return methodCall.getArguments().stream() .filter(arg->arg instanceof NonPrimitiveArgument) .noneMatch(arg -> aux_someEntityInterfereWithDescribingAnEntityInArg((NonPrimitiveArgument)arg, primitiveTriples, idsOfNonPrimitiveEntitiesInPrimitiveRelations)); }
Hit implements Serializable { public boolean isQueryableByPrimitiveRelations() { Collection<KBTriple> primitiveTriples = initialState.getGraphKb().getTriples().stream() .filter(triple -> triple.secondEntity instanceof PrimitiveEntity) .collect(Collectors.toList()); Set<String> idsOfNonPrimitiveEntitiesInPrimitiveRelations = primitiveTriples.stream() .map(triple -> initialState.getEntityId(triple.firstEntity)) .collect(Collectors.toSet()); return methodCall.getArguments().stream() .filter(arg->arg instanceof NonPrimitiveArgument) .noneMatch(arg -> aux_someEntityInterfereWithDescribingAnEntityInArg((NonPrimitiveArgument)arg, primitiveTriples, idsOfNonPrimitiveEntitiesInPrimitiveRelations)); } }
Hit implements Serializable { public boolean isQueryableByPrimitiveRelations() { Collection<KBTriple> primitiveTriples = initialState.getGraphKb().getTriples().stream() .filter(triple -> triple.secondEntity instanceof PrimitiveEntity) .collect(Collectors.toList()); Set<String> idsOfNonPrimitiveEntitiesInPrimitiveRelations = primitiveTriples.stream() .map(triple -> initialState.getEntityId(triple.firstEntity)) .collect(Collectors.toSet()); return methodCall.getArguments().stream() .filter(arg->arg instanceof NonPrimitiveArgument) .noneMatch(arg -> aux_someEntityInterfereWithDescribingAnEntityInArg((NonPrimitiveArgument)arg, primitiveTriples, idsOfNonPrimitiveEntitiesInPrimitiveRelations)); } Hit(String id, Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, ZonedDateTime creationTime);  Hit(Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, String idPrefix,
               ZonedDateTime creationTime); }
Hit implements Serializable { public boolean isQueryableByPrimitiveRelations() { Collection<KBTriple> primitiveTriples = initialState.getGraphKb().getTriples().stream() .filter(triple -> triple.secondEntity instanceof PrimitiveEntity) .collect(Collectors.toList()); Set<String> idsOfNonPrimitiveEntitiesInPrimitiveRelations = primitiveTriples.stream() .map(triple -> initialState.getEntityId(triple.firstEntity)) .collect(Collectors.toSet()); return methodCall.getArguments().stream() .filter(arg->arg instanceof NonPrimitiveArgument) .noneMatch(arg -> aux_someEntityInterfereWithDescribingAnEntityInArg((NonPrimitiveArgument)arg, primitiveTriples, idsOfNonPrimitiveEntitiesInPrimitiveRelations)); } Hit(String id, Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, ZonedDateTime creationTime);  Hit(Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, String idPrefix,
               ZonedDateTime creationTime); State getDestinationState(); @Override boolean equals(Object obj); @Override int hashCode(); String getId(); State getInitialState(); HitConstructionInfo getHitConstructionInfo(); MethodCall getMethodCall(); Domain getDomain(); PngFileInMemo createInitialAndDesiredStatesFigure(HitConstructionSettings hitConstructionSettings); boolean isQueryableByPrimitiveRelations(); boolean containsArgQueryableByComparisonOperation(); boolean containsArgQueryableBySuperlativeOperation(); String extractBatchIdFromHitIdAssumingExpectedFormat(); @Override String toString(); }
Hit implements Serializable { public boolean isQueryableByPrimitiveRelations() { Collection<KBTriple> primitiveTriples = initialState.getGraphKb().getTriples().stream() .filter(triple -> triple.secondEntity instanceof PrimitiveEntity) .collect(Collectors.toList()); Set<String> idsOfNonPrimitiveEntitiesInPrimitiveRelations = primitiveTriples.stream() .map(triple -> initialState.getEntityId(triple.firstEntity)) .collect(Collectors.toSet()); return methodCall.getArguments().stream() .filter(arg->arg instanceof NonPrimitiveArgument) .noneMatch(arg -> aux_someEntityInterfereWithDescribingAnEntityInArg((NonPrimitiveArgument)arg, primitiveTriples, idsOfNonPrimitiveEntitiesInPrimitiveRelations)); } Hit(String id, Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, ZonedDateTime creationTime);  Hit(Domain domain, State initialState, State destinationState, MethodCall methodCall,
               StateVisualizer initialStateVisualizer, StateVisualizer desiredStateVisualizer, String idPrefix,
               ZonedDateTime creationTime); State getDestinationState(); @Override boolean equals(Object obj); @Override int hashCode(); String getId(); State getInitialState(); HitConstructionInfo getHitConstructionInfo(); MethodCall getMethodCall(); Domain getDomain(); PngFileInMemo createInitialAndDesiredStatesFigure(HitConstructionSettings hitConstructionSettings); boolean isQueryableByPrimitiveRelations(); boolean containsArgQueryableByComparisonOperation(); boolean containsArgQueryableBySuperlativeOperation(); String extractBatchIdFromHitIdAssumingExpectedFormat(); @Override String toString();  }