Skip to content

Commit

Permalink
Fixes for Issue Impetus#308.
Browse files Browse the repository at this point in the history
Commented out jacoco plugin
  • Loading branch information
mevivs committed Jul 5, 2013
1 parent 60d85d8 commit b978bf2
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 70 deletions.
8 changes: 4 additions & 4 deletions kundera-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@
<!-- <parallel>tests</parallel> <threadCount>10</threadCount> -->
</configuration>
</plugin>
<plugin>
<!-- <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<!-- The destination file for the code coverage report has to be set
The destination file for the code coverage report has to be set
to the same value in the parent pom and in each module pom. Then JaCoCo will
add up information in the same report, so that, it will give the cross-module
code coverage. -->
code coverage.
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
</configuration>
<executions>
Expand All @@ -192,7 +192,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin> -->
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version> <configuration> <forkCount>10</forkCount> <reuseForks>true</reuseForks>
<argLine>-Xmx512M</argLine> </configuration> </plugin> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ public KunderaQuery getKunderaQuery()
return kunderaQuery;
}

/**
* Sets the kundera query.
*
* @param kunderaQuery
* the kunderaQuery to set
*/
public void setKunderaQuery(KunderaQuery kunderaQuery)
{
this.kunderaQuery = kunderaQuery;
}

@Override
public int executeUpdate()
{
Expand Down Expand Up @@ -181,26 +170,6 @@ public List<?> getResultList()
return results != null ? results : new ArrayList();
}

/**
* Gets the persistence delegeator.
*
* @return the persistenceDelegeator
*/
public PersistenceDelegator getPersistenceDelegeator()
{
return persistenceDelegeator;
}

/**
* Sets the persistence delegeator.
*
* @param persistenceDelegeator
* the persistenceDelegeator to set
*/
public void setPersistenceDelegeator(PersistenceDelegator persistenceDelegeator)
{
this.persistenceDelegeator = persistenceDelegeator;
}

protected List<Object> setRelationEntities(List enhanceEntities, Client client, EntityMetadata m)
{
Expand Down
109 changes: 109 additions & 0 deletions kundera-core/src/test/java/com/impetus/kundera/query/CoreQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* Copyright 2013 Impetus Infotech.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.impetus.kundera.query;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.impetus.kundera.client.Client;
import com.impetus.kundera.metadata.model.EntityMetadata;
import com.impetus.kundera.persistence.EntityReader;
import com.impetus.kundera.persistence.PersistenceDelegator;
import com.impetus.kundera.query.QueryImpl;
import com.impetus.kundera.query.KunderaQuery.FilterClause;

/**
* @author vivek.mishra
* Test implementation for {@link Query} interface.
*
*/
public class CoreQuery<E> extends QueryImpl<E>
{

public CoreQuery(String query, final KunderaQuery kunderaQuery, PersistenceDelegator persistenceDelegator)
{
super(query, persistenceDelegator);
this.kunderaQuery = kunderaQuery;
}


public List getResutList()
{
return super.getResultList();
}

@Override
protected List<Object> populateEntities(EntityMetadata m, Client client)
{
// Only find by id queries supported.

EntityMetadata entityMetadata = getEntityMetadata();
Object value = null;
for(Object clause: getKunderaQuery().getFilterClauseQueue())
{
if(clause instanceof FilterClause)
{
String property = ((FilterClause)clause).getProperty();
String condition = ((FilterClause)clause).getCondition();
value = ((FilterClause)clause).getValue();
}



}

Object result = client.find(m.getEntityClazz(), value);
List results = new ArrayList();
if(result != null)
{
results.add(result);
}
return results;
}

@Override
protected List<Object> recursivelyPopulateEntities(EntityMetadata m, Client client)
{
return null;
}

@Override
protected EntityReader getReader()
{
return new CoreTestEntityReader();
}

@Override
protected int onExecuteUpdate()
{
return getResultList().size();
}

@Override
public void close()
{
// Do nothing.

}

@Override
public Iterator<E> iterate()
{
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* Copyright 2013 Impetus Infotech.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.impetus.kundera.query;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.impetus.kundera.CoreTestUtilities;
import com.impetus.kundera.client.DummyDatabase;
import com.impetus.kundera.metadata.model.KunderaMetadata;
import com.impetus.kundera.persistence.PersistenceDelegator;
import com.impetus.kundera.query.Person.Day;

/**
* @author vivek.mishra
* junit for {@link QueryImpl}
*
*/
public class QueryImplTest
{

private static final String PU = "patest";

private EntityManagerFactory emf;

private EntityManager em;

/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception
{
KunderaMetadata.INSTANCE.setApplicationMetadata(null);
emf = Persistence.createEntityManagerFactory(PU);
em = emf.createEntityManager();

}

@Test
public void test() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
{
Person p1 = new Person();
p1.setAge(98);
p1.setPersonId("1");
p1.setDay(Day.SATURDAY);

em.persist(p1);

em.clear();

Person p2 = new Person();
p2.setAge(100);
p2.setPersonId("2");
p2.setDay(Day.SATURDAY);

em.persist(p2);

final String query = "Select p from Person p where p.personId = '1'";

PersistenceDelegator delegator = CoreTestUtilities.getDelegator(em);

KunderaQueryParser queryParser;
KunderaQuery kunderaQuery = parseQuery(query);

CoreQuery queryObj = new CoreQuery(query, kunderaQuery, delegator);

List<Person> results = queryObj.getResultList();

Assert.assertEquals(1,results.size());


final String deleteQuery = "Delete from Person p where p.personId = '1'";

kunderaQuery = parseQuery(deleteQuery);
queryObj = new CoreQuery(query, kunderaQuery, delegator);

queryObj.executeUpdate();


kunderaQuery = parseQuery(query);
queryObj = new CoreQuery(query, kunderaQuery, delegator);

results = queryObj.getResultList();

Assert.assertEquals(0,results.size());
}

private KunderaQuery parseQuery(final String query)
{
KunderaQuery kunderaQuery = new KunderaQuery();
KunderaQueryParser queryParser = new KunderaQueryParser(kunderaQuery, query);
queryParser.parse();
kunderaQuery.postParsingInit();
return kunderaQuery;
}


@After
public void tearDown()
{
DummyDatabase.INSTANCE.dropDatabase();
}
}
8 changes: 4 additions & 4 deletions kundera-hbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@
</configuration>
</plugin>

<plugin>
<!-- <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<!-- The destination file for the code coverage report has to be set
The destination file for the code coverage report has to be set
to the same value in the parent pom and in each module pom. Then JaCoCo will
add up information in the same report, so that, it will give the cross-module
code coverage. -->
code coverage.
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
</configuration>
<executions>
Expand All @@ -147,7 +147,7 @@
</configuration>
</execution>
</executions>
</plugin> <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
</plugin> --> <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version> <configuration> <excludes> <exclude>**/datatypes/*.java</exclude>
</excludes> </configuration> </plugin> -->
</plugins>
Expand Down
8 changes: 4 additions & 4 deletions kundera-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<!-- The destination file for the code coverage report has to be set
The destination file for the code coverage report has to be set
to the same value in the parent pom and in each module pom. Then JaCoCo will
add up information in the same report, so that, it will give the cross-module
code coverage. -->
code coverage.
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
</configuration>
<executions>
Expand All @@ -93,7 +93,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin> -->
</plugins>
</build>

Expand Down
8 changes: 4 additions & 4 deletions kundera-neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<!-- The destination file for the code coverage report has to be set
The destination file for the code coverage report has to be set
to the same value in the parent pom and in each module pom. Then JaCoCo will
add up information in the same report, so that, it will give the cross-module
code coverage. -->
code coverage.
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
</configuration>
<executions>
Expand All @@ -112,7 +112,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin> -->
</plugins>
</build>
</project>
Loading

0 comments on commit b978bf2

Please sign in to comment.