repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
ivargrimstad/snoopee | snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/api/ServicesResource.java | // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEClientRegistry.java
// @Singleton
// public class SnoopEEClientRegistry {
//
// private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
//
// private final Map<String, Long> clients = new ConcurrentHashMap<>();
// private final Map<String, SnoopEEConfig> clientConfigurations = new ConcurrentHashMap<>();
//
// public void register(final SnoopEEConfig client) {
// Calendar now = getInstance();
// clients.put(client.getServiceName(), now.getTimeInMillis());
// clientConfigurations.put(client.getServiceName(), client);
//
// LOGGER.config(() -> "Client: " + client.getServiceName() + " registered up at " + now.getTime());
// }
//
// public void deRegister(final String clientId) {
// clients.remove(clientId);
// clientConfigurations.remove(clientId);
//
// LOGGER.warning(() -> "Client: " + clientId + " deregistered at " + Calendar.getInstance().getTime());
// }
//
// public Set<String> getClients() {
//
// return clients.keySet().stream()
// .filter(c -> clients.get(c) > System.currentTimeMillis() - 60000)
// .collect(Collectors.toSet());
// }
//
// public Collection<SnoopEEConfig> getServiceConfigs() {
// return clientConfigurations.values();
// }
//
// public Optional<SnoopEEConfig> getClientConfig(String clientId) {
//
// if (getClients().contains(clientId)) {
//
// return Optional.ofNullable(clientConfigurations.get(clientId));
//
// } else {
// return Optional.empty();
// }
// }
// }
//
// Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
| import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.GenericEntity;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import eu.agilejava.snoopee.SnoopEEClientRegistry;
import eu.agilejava.snoopee.SnoopEEConfig;
import java.util.Collection;
import javax.ejb.EJB;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException; | /*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.api;
/**
*
* @author Ivar Grimstad ([email protected])
*/
@Path("services")
public class ServicesResource {
@Context
private UriInfo uriInfo;
@EJB
private SnoopEEClientRegistry snoopeeClientRegistry;
@GET
@Produces(APPLICATION_JSON)
public Response all() {
| // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEClientRegistry.java
// @Singleton
// public class SnoopEEClientRegistry {
//
// private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
//
// private final Map<String, Long> clients = new ConcurrentHashMap<>();
// private final Map<String, SnoopEEConfig> clientConfigurations = new ConcurrentHashMap<>();
//
// public void register(final SnoopEEConfig client) {
// Calendar now = getInstance();
// clients.put(client.getServiceName(), now.getTimeInMillis());
// clientConfigurations.put(client.getServiceName(), client);
//
// LOGGER.config(() -> "Client: " + client.getServiceName() + " registered up at " + now.getTime());
// }
//
// public void deRegister(final String clientId) {
// clients.remove(clientId);
// clientConfigurations.remove(clientId);
//
// LOGGER.warning(() -> "Client: " + clientId + " deregistered at " + Calendar.getInstance().getTime());
// }
//
// public Set<String> getClients() {
//
// return clients.keySet().stream()
// .filter(c -> clients.get(c) > System.currentTimeMillis() - 60000)
// .collect(Collectors.toSet());
// }
//
// public Collection<SnoopEEConfig> getServiceConfigs() {
// return clientConfigurations.values();
// }
//
// public Optional<SnoopEEConfig> getClientConfig(String clientId) {
//
// if (getClients().contains(clientId)) {
//
// return Optional.ofNullable(clientConfigurations.get(clientId));
//
// } else {
// return Optional.empty();
// }
// }
// }
//
// Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
// Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/api/ServicesResource.java
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.GenericEntity;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import eu.agilejava.snoopee.SnoopEEClientRegistry;
import eu.agilejava.snoopee.SnoopEEConfig;
import java.util.Collection;
import javax.ejb.EJB;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
/*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.api;
/**
*
* @author Ivar Grimstad ([email protected])
*/
@Path("services")
public class ServicesResource {
@Context
private UriInfo uriInfo;
@EJB
private SnoopEEClientRegistry snoopeeClientRegistry;
@GET
@Produces(APPLICATION_JSON)
public Response all() {
| final Collection<SnoopEEConfig> serviceConfigs = snoopeeClientRegistry.getServiceConfigs(); |
ivargrimstad/snoopee | snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/config/ApplicatonConfig.java | // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/api/ServicesResource.java
// @Path("services")
// public class ServicesResource {
//
// @Context
// private UriInfo uriInfo;
//
// @EJB
// private SnoopEEClientRegistry snoopeeClientRegistry;
//
// @GET
// @Produces(APPLICATION_JSON)
// public Response all() {
//
// final Collection<SnoopEEConfig> serviceConfigs = snoopeeClientRegistry.getServiceConfigs();
//
// return Response.ok(new GenericEntity<Collection<SnoopEEConfig>>(serviceConfigs) {
// })
// .header("Access-Control-Allow-Origin", "*").build();
// }
//
// @GET
// @Produces(APPLICATION_JSON)
// @Path("{serviceId}")
// public Response lookup(@PathParam("serviceId") String serviceId) {
//
// return Response.ok(snoopeeClientRegistry.getClientConfig(serviceId)
// .orElseThrow(NotFoundException::new)).build();
// }
//
// @POST
// public Response register(final SnoopEEConfig serviceConfig) {
// snoopeeClientRegistry.register(serviceConfig);
// return Response.created(uriInfo.getAbsolutePathBuilder().segment(serviceConfig.getServiceName()).build()).build();
// }
//
// @PUT
// @Path("{serviceName}")
// public Response updateStatus(@PathParam("serviceName") String serviceName, final SnoopEEConfig serviceConfig) {
// if (serviceConfig != null) {
// snoopeeClientRegistry.register(serviceConfig);
// } else {
// snoopeeClientRegistry.deRegister(serviceName);
// }
// return Response.ok().build();
// }
//
// @DELETE
// @Path("{serviceName}")
// public Response deRegister(@PathParam("serviceName") String serviceName) {
// snoopeeClientRegistry.deRegister(serviceName);
// return Response.accepted().build();
// }
//
// }
| import eu.agilejava.snoopee.api.ServicesResource;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; | /*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.config;
/**
*
* @author Ivar Grimstad ([email protected])
*/
@ApplicationPath("api")
public class ApplicatonConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>(); | // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/api/ServicesResource.java
// @Path("services")
// public class ServicesResource {
//
// @Context
// private UriInfo uriInfo;
//
// @EJB
// private SnoopEEClientRegistry snoopeeClientRegistry;
//
// @GET
// @Produces(APPLICATION_JSON)
// public Response all() {
//
// final Collection<SnoopEEConfig> serviceConfigs = snoopeeClientRegistry.getServiceConfigs();
//
// return Response.ok(new GenericEntity<Collection<SnoopEEConfig>>(serviceConfigs) {
// })
// .header("Access-Control-Allow-Origin", "*").build();
// }
//
// @GET
// @Produces(APPLICATION_JSON)
// @Path("{serviceId}")
// public Response lookup(@PathParam("serviceId") String serviceId) {
//
// return Response.ok(snoopeeClientRegistry.getClientConfig(serviceId)
// .orElseThrow(NotFoundException::new)).build();
// }
//
// @POST
// public Response register(final SnoopEEConfig serviceConfig) {
// snoopeeClientRegistry.register(serviceConfig);
// return Response.created(uriInfo.getAbsolutePathBuilder().segment(serviceConfig.getServiceName()).build()).build();
// }
//
// @PUT
// @Path("{serviceName}")
// public Response updateStatus(@PathParam("serviceName") String serviceName, final SnoopEEConfig serviceConfig) {
// if (serviceConfig != null) {
// snoopeeClientRegistry.register(serviceConfig);
// } else {
// snoopeeClientRegistry.deRegister(serviceName);
// }
// return Response.ok().build();
// }
//
// @DELETE
// @Path("{serviceName}")
// public Response deRegister(@PathParam("serviceName") String serviceName) {
// snoopeeClientRegistry.deRegister(serviceName);
// return Response.accepted().build();
// }
//
// }
// Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/config/ApplicatonConfig.java
import eu.agilejava.snoopee.api.ServicesResource;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.config;
/**
*
* @author Ivar Grimstad ([email protected])
*/
@ApplicationPath("api")
public class ApplicatonConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>(); | classes.add(ServicesResource.class); |
ivargrimstad/snoopee | snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEEndpoint.java | // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEConfig.java
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
| import static eu.agilejava.snoopee.SnoopEEConfig.fromJSON;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.websocket.OnMessage;
import javax.websocket.server.ServerEndpoint; | /*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee;
/**
* WebSocket endpoint for client registration.
*
* @author Ivar Grimstad ([email protected])
*/
@ServerEndpoint("/snoopee")
@Stateless
public class SnoopEEEndpoint {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
@EJB
private SnoopEEClientRegistry clients;
@OnMessage
public String onMessage(String message) {
LOGGER.config(() -> "Registering: " + message);
| // Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEConfig.java
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// Path: snoopee-discovery/snoopee-service/src/main/java/eu/agilejava/snoopee/SnoopEEEndpoint.java
import static eu.agilejava.snoopee.SnoopEEConfig.fromJSON;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.websocket.OnMessage;
import javax.websocket.server.ServerEndpoint;
/*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee;
/**
* WebSocket endpoint for client registration.
*
* @author Ivar Grimstad ([email protected])
*/
@ServerEndpoint("/snoopee")
@Stateless
public class SnoopEEEndpoint {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
@EJB
private SnoopEEClientRegistry clients;
@OnMessage
public String onMessage(String message) {
LOGGER.config(() -> "Registering: " + message);
| SnoopEEConfig client = fromJSON(message); |
ivargrimstad/snoopee | snoopee-discovery/snoopee/src/main/java/eu/agilejava/snoopee/scan/SnoopEEScannerExtension.java | // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEExtensionHelper.java
// public final class SnoopEEExtensionHelper {
//
// private String serviceName;
// private boolean snoopEnabled;
//
// private static final SnoopEEExtensionHelper INSTANCE = new SnoopEEExtensionHelper();
//
// public static String getServiceName() {
// return INSTANCE.serviceName;
// }
//
// public static void setServiceName(String serviceName) {
// INSTANCE.serviceName = serviceName;
// }
//
// public static boolean isSnoopEnabled() {
// return INSTANCE.snoopEnabled;
// }
//
// public static void setSnoopEnabled(final boolean snoopEnabled) {
// INSTANCE.snoopEnabled = snoopEnabled;
// }
// }
| import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.inject.spi.WithAnnotations;
import eu.agilejava.snoopee.annotation.EnableSnoopEEClient;
import eu.agilejava.snoopee.SnoopEEExtensionHelper;
import java.util.logging.Logger;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension; | /*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.scan;
/**
* CDI Extension that scans for @EnableSnoopEEClient annotations.
*
* @author Ivar Grimstad ([email protected])
*/
public class SnoopEEScannerExtension implements Extension {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
private String serviceName;
private boolean snoopEnabled;
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) {
LOGGER.config("Scanning for SnoopEE clients");
}
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
LOGGER.config("Discovering SnoopEE clients"); | // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEExtensionHelper.java
// public final class SnoopEEExtensionHelper {
//
// private String serviceName;
// private boolean snoopEnabled;
//
// private static final SnoopEEExtensionHelper INSTANCE = new SnoopEEExtensionHelper();
//
// public static String getServiceName() {
// return INSTANCE.serviceName;
// }
//
// public static void setServiceName(String serviceName) {
// INSTANCE.serviceName = serviceName;
// }
//
// public static boolean isSnoopEnabled() {
// return INSTANCE.snoopEnabled;
// }
//
// public static void setSnoopEnabled(final boolean snoopEnabled) {
// INSTANCE.snoopEnabled = snoopEnabled;
// }
// }
// Path: snoopee-discovery/snoopee/src/main/java/eu/agilejava/snoopee/scan/SnoopEEScannerExtension.java
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.inject.spi.WithAnnotations;
import eu.agilejava.snoopee.annotation.EnableSnoopEEClient;
import eu.agilejava.snoopee.SnoopEEExtensionHelper;
import java.util.logging.Logger;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
/*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.scan;
/**
* CDI Extension that scans for @EnableSnoopEEClient annotations.
*
* @author Ivar Grimstad ([email protected])
*/
public class SnoopEEScannerExtension implements Extension {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
private String serviceName;
private boolean snoopEnabled;
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) {
LOGGER.config("Scanning for SnoopEE clients");
}
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
LOGGER.config("Discovering SnoopEE clients"); | SnoopEEExtensionHelper.setServiceName(serviceName); |
ivargrimstad/snoopee | snoopee-discovery/snoopee-micro/src/main/java/eu/agilejava/snoopee/scan/SnoopEERegistrationClient.java | // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEConfigurationException.java
// public class SnoopEEConfigurationException extends RuntimeException {
//
// public SnoopEEConfigurationException(String message) {
// super(message);
// }
// }
//
// Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/client/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
| import eu.agilejava.snoopee.SnoopEEConfigurationException;
import eu.agilejava.snoopee.annotation.SnoopEEClient;
import eu.agilejava.snoopee.client.SnoopEEConfig;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | /*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.scan;
/**
* Registers with SnoopEE and gives heartbeats every 10 second.
*
* @author Ivar Grimstad ([email protected])
*/
@SnoopEEClient
public class SnoopEERegistrationClient {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
@Inject
@ConfigProperty(name = "snoopeeService", defaultValue = "http://localhost:8081/snoopee-service/jalla")
private String serviceUrl;
@Inject
@ConfigProperty(name="port")
private int port;
@Inject
@ConfigProperty(name="host")
private String host;
@Inject
@ConfigProperty(name = "serviceRoot", defaultValue = "/")
private String serviceRoot;
| // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEConfigurationException.java
// public class SnoopEEConfigurationException extends RuntimeException {
//
// public SnoopEEConfigurationException(String message) {
// super(message);
// }
// }
//
// Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/client/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
// Path: snoopee-discovery/snoopee-micro/src/main/java/eu/agilejava/snoopee/scan/SnoopEERegistrationClient.java
import eu.agilejava.snoopee.SnoopEEConfigurationException;
import eu.agilejava.snoopee.annotation.SnoopEEClient;
import eu.agilejava.snoopee.client.SnoopEEConfig;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
/*
* The MIT License
*
* Copyright 2015 Ivar Grimstad ([email protected]).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package eu.agilejava.snoopee.scan;
/**
* Registers with SnoopEE and gives heartbeats every 10 second.
*
* @author Ivar Grimstad ([email protected])
*/
@SnoopEEClient
public class SnoopEERegistrationClient {
private static final Logger LOGGER = Logger.getLogger("eu.agilejava.snoopee");
@Inject
@ConfigProperty(name = "snoopeeService", defaultValue = "http://localhost:8081/snoopee-service/jalla")
private String serviceUrl;
@Inject
@ConfigProperty(name="port")
private int port;
@Inject
@ConfigProperty(name="host")
private String host;
@Inject
@ConfigProperty(name = "serviceRoot", defaultValue = "/")
private String serviceRoot;
| private final SnoopEEConfig applicationConfig = new SnoopEEConfig(); |
ivargrimstad/snoopee | snoopee-discovery/snoopee-micro/src/main/java/eu/agilejava/snoopee/scan/SnoopEERegistrationClient.java | // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEConfigurationException.java
// public class SnoopEEConfigurationException extends RuntimeException {
//
// public SnoopEEConfigurationException(String message) {
// super(message);
// }
// }
//
// Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/client/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
| import eu.agilejava.snoopee.SnoopEEConfigurationException;
import eu.agilejava.snoopee.annotation.SnoopEEClient;
import eu.agilejava.snoopee.client.SnoopEEConfig;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON; | private String serviceRoot;
private final SnoopEEConfig applicationConfig = new SnoopEEConfig();
private Timer timer;
@Inject
private Event<SnoopEEConfig> configuredEvent;
private void init(@Observes @Initialized(ApplicationScoped.class) Object init) {
LOGGER.config("Checking if SnoopEE is enabled");
if (SnoopEEExtensionHelper.isSnoopEnabled()) {
Client client = ClientBuilder.newClient();
try {
readConfiguration();
LOGGER.config(() -> "Registering " + applicationConfig.getServiceName());
Response response = client
.target(serviceUrl)
.path("api")
.path("services")
.request()
.post(Entity.entity(applicationConfig, APPLICATION_JSON));
LOGGER.config(() -> "Fire health event");
configuredEvent.fire(applicationConfig);
| // Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/SnoopEEConfigurationException.java
// public class SnoopEEConfigurationException extends RuntimeException {
//
// public SnoopEEConfigurationException(String message) {
// super(message);
// }
// }
//
// Path: snoopee-discovery/snoopee-client/src/main/java/eu/agilejava/snoopee/client/SnoopEEConfig.java
// public class SnoopEEConfig {
//
// private String serviceName;
// private String serviceHome;
// private String serviceRoot;
//
// public String getServiceName() {
// return serviceName;
// }
//
// public void setServiceName(String serviceName) {
// this.serviceName = serviceName;
// }
//
// public String getServiceHome() {
// return serviceHome;
// }
//
// public void setServiceHome(String serviceHome) {
// this.serviceHome = serviceHome;
// }
//
// public String getServiceRoot() {
// return serviceRoot;
// }
//
// public void setServiceRoot(String serviceRoot) {
// this.serviceRoot = serviceRoot;
// }
//
// public String toJSON() {
//
// Writer w = new StringWriter();
// try (JsonGenerator generator = Json.createGenerator(w)) {
//
// generator.writeStartObject()
// .write("serviceName", serviceName)
// .write("serviceHome", serviceHome)
// .write("serviceRoot", serviceRoot)
// .writeEnd();
// }
//
// return w.toString();
// }
//
// public static SnoopEEConfig fromJSON(String json) {
//
// SnoopEEConfig config = new SnoopEEConfig();
//
// try (JsonReader reader = Json.createReader(new StringReader(json))) {
//
// JsonObject configJson = reader.readObject();
//
// config.setServiceName(configJson.getString("serviceName"));
// config.setServiceHome(configJson.getString("serviceHome"));
// config.setServiceRoot(configJson.getString("serviceRoot"));
// }
//
// return config;
// }
// }
// Path: snoopee-discovery/snoopee-micro/src/main/java/eu/agilejava/snoopee/scan/SnoopEERegistrationClient.java
import eu.agilejava.snoopee.SnoopEEConfigurationException;
import eu.agilejava.snoopee.annotation.SnoopEEClient;
import eu.agilejava.snoopee.client.SnoopEEConfig;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
private String serviceRoot;
private final SnoopEEConfig applicationConfig = new SnoopEEConfig();
private Timer timer;
@Inject
private Event<SnoopEEConfig> configuredEvent;
private void init(@Observes @Initialized(ApplicationScoped.class) Object init) {
LOGGER.config("Checking if SnoopEE is enabled");
if (SnoopEEExtensionHelper.isSnoopEnabled()) {
Client client = ClientBuilder.newClient();
try {
readConfiguration();
LOGGER.config(() -> "Registering " + applicationConfig.getServiceName());
Response response = client
.target(serviceUrl)
.path("api")
.path("services")
.request()
.post(Entity.entity(applicationConfig, APPLICATION_JSON));
LOGGER.config(() -> "Fire health event");
configuredEvent.fire(applicationConfig);
| } catch (SnoopEEConfigurationException e) { |
PaulKlinger/Sprog-App | app/src/main/java/com/almoturg/sprog/model/Poem.java | // Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public final class Util {
// public static <T> T last(T[] array) {
// return array[array.length - 1];
// }
//
// @SuppressWarnings("deprecation")
// public static Spanned fromHtml(String source) {
// // This converts html to Spanned.
// // fromHtml(String) is deprecated in Nougat so we need to check the version.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
// } else {
// return Html.fromHtml(source);
// }
// }
//
// public static int getDisplayWidthDp(Context context) {
// Configuration configuration = context.getResources().getConfiguration();
// return configuration.screenWidthDp;
// }
//
// public static Spanned linkToSpan(String link) {
// return fromHtml(String.format("<a href=\"%s\">%s</a>", link, link));
// }
//
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// public static int getThemeReference(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, false);
// return value.data;
// }
//
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// }
| import com.almoturg.sprog.util.Util;
import java.util.List; | this.timestamp = timestamp;
this.timestamp_long = (long) timestamp * 1000;
this.post_title = post_title;
this.post_author = post_author;
this.post_content = post_content;
this.post_url = post_url;
this.parents = parents;
this.link = link;
this.main_poem = main_poem;
this.first_line = first_line;
this.read = is_read;
this.favorite = is_favorite;
}
public void toggleFavorite(SprogDbHelper db){
this.favorite = !this.favorite;
if (this.favorite) {
db.addFavoritePoem(this.link);
} else {
db.removeFavoritePoem(this.link);
}
}
public int totalAwards(){
return 3 * this.platinum + 2 * this.gold + this.silver;
}
public String getId() { | // Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public final class Util {
// public static <T> T last(T[] array) {
// return array[array.length - 1];
// }
//
// @SuppressWarnings("deprecation")
// public static Spanned fromHtml(String source) {
// // This converts html to Spanned.
// // fromHtml(String) is deprecated in Nougat so we need to check the version.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
// } else {
// return Html.fromHtml(source);
// }
// }
//
// public static int getDisplayWidthDp(Context context) {
// Configuration configuration = context.getResources().getConfiguration();
// return configuration.screenWidthDp;
// }
//
// public static Spanned linkToSpan(String link) {
// return fromHtml(String.format("<a href=\"%s\">%s</a>", link, link));
// }
//
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// public static int getThemeReference(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, false);
// return value.data;
// }
//
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// }
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
import com.almoturg.sprog.util.Util;
import java.util.List;
this.timestamp = timestamp;
this.timestamp_long = (long) timestamp * 1000;
this.post_title = post_title;
this.post_author = post_author;
this.post_content = post_content;
this.post_url = post_url;
this.parents = parents;
this.link = link;
this.main_poem = main_poem;
this.first_line = first_line;
this.read = is_read;
this.favorite = is_favorite;
}
public void toggleFavorite(SprogDbHelper db){
this.favorite = !this.favorite;
if (this.favorite) {
db.addFavoritePoem(this.link);
} else {
db.removeFavoritePoem(this.link);
}
}
public int totalAwards(){
return 3 * this.platinum + 2 * this.gold + this.silver;
}
public String getId() { | return Util.last(this.link.split("/")); |
PaulKlinger/Sprog-App | app/src/main/java/com/almoturg/sprog/view/Graphs.java | // Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public final class Util {
// public static <T> T last(T[] array) {
// return array[array.length - 1];
// }
//
// @SuppressWarnings("deprecation")
// public static Spanned fromHtml(String source) {
// // This converts html to Spanned.
// // fromHtml(String) is deprecated in Nougat so we need to check the version.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
// } else {
// return Html.fromHtml(source);
// }
// }
//
// public static int getDisplayWidthDp(Context context) {
// Configuration configuration = context.getResources().getConfiguration();
// return configuration.screenWidthDp;
// }
//
// public static Spanned linkToSpan(String link) {
// return fromHtml(String.format("<a href=\"%s\">%s</a>", link, link));
// }
//
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// public static int getThemeReference(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, false);
// return value.data;
// }
//
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// }
| import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import com.almoturg.sprog.R;
import com.almoturg.sprog.util.Util;
import com.androidplot.xy.BarFormatter;
import com.androidplot.xy.BarRenderer;
import com.androidplot.xy.BoundaryMode;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.PanZoom;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.StepMode;
import com.androidplot.xy.XYGraphWidget;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYSeries;
import com.annimon.stream.Stream;
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.List; | package com.almoturg.sprog.view;
public class Graphs {
public static final int BAR = 1;
public static final int LINE = 2;
public static void initGraph(Context context, XYPlot plot, List<Number> xs, List<Number> ys, int type, int yStep) {
XYSeries data = new SimpleXYSeries(xs, ys, "");
if (type == BAR) {
BarFormatter formatter = new BarFormatter( | // Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public final class Util {
// public static <T> T last(T[] array) {
// return array[array.length - 1];
// }
//
// @SuppressWarnings("deprecation")
// public static Spanned fromHtml(String source) {
// // This converts html to Spanned.
// // fromHtml(String) is deprecated in Nougat so we need to check the version.
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
// } else {
// return Html.fromHtml(source);
// }
// }
//
// public static int getDisplayWidthDp(Context context) {
// Configuration configuration = context.getResources().getConfiguration();
// return configuration.screenWidthDp;
// }
//
// public static Spanned linkToSpan(String link) {
// return fromHtml(String.format("<a href=\"%s\">%s</a>", link, link));
// }
//
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// public static int getThemeReference(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, false);
// return value.data;
// }
//
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// }
// Path: app/src/main/java/com/almoturg/sprog/view/Graphs.java
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import com.almoturg.sprog.R;
import com.almoturg.sprog.util.Util;
import com.androidplot.xy.BarFormatter;
import com.androidplot.xy.BarRenderer;
import com.androidplot.xy.BoundaryMode;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.PanZoom;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.StepMode;
import com.androidplot.xy.XYGraphWidget;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYSeries;
import com.annimon.stream.Stream;
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.List;
package com.almoturg.sprog.view;
public class Graphs {
public static final int BAR = 1;
public static final int LINE = 2;
public static void initGraph(Context context, XYPlot plot, List<Number> xs, List<Number> ys, int type, int yStep) {
XYSeries data = new SimpleXYSeries(xs, ys, "");
if (type == BAR) {
BarFormatter formatter = new BarFormatter( | Util.getThemeColor(context, R.attr.colorAccent), Color.TRANSPARENT); |
PaulKlinger/Sprog-App | app/src/test/java/com/almoturg/sprog/UpdateHelpersTest.java | // Path: app/src/main/java/com/almoturg/sprog/data/UpdateHelpers.java
// public class UpdateHelpers {
// // These are the times when an update should be available on the server
// private static final int FIRST_UPDATE_HOUR = 2;
// private static final int SECOND_UPDATE_HOUR = 14;
// private static final long MIN_HOURS_BETWEEN_UPDATES = 11; // some margin if it runs faster
// private static final long MAX_DAYS_BETWEEN_LOADING_POEMS = 3;
// private static final long MAX_DAYS_BETWEEN_FULL_UPDATES = 30;
//
// // minimum length of poems.json file in bytes such that it is assumed to be complete
// // and therefore the cancel button is shown when updating
// private static final int MIN_FILE_LENGTH = 1000 * 1000;
//
// public static boolean isUpdateTime(Calendar now,
// long last_update_tstamp, long last_fcm_tstamp) {
// // Always load JSON when more than MAX_DAYS_BETWEEN_LOADING_POEMS days have passed
// // This is mainly to get updated scores/gold counts and to remove deleted poems.
// if (now.getTimeInMillis() - last_update_tstamp >
// MAX_DAYS_BETWEEN_LOADING_POEMS * 24 * 60 * 60 * 1000) {
// return true;
// }
//
// // last_fcm_tstamp is the time when the last FCM message was sent
// // if it showed that updates were available this function would not have been called
// if (now.getTimeInMillis() - last_fcm_tstamp < MIN_HOURS_BETWEEN_UPDATES * 60 * 60 * 1000) {
// return false;
// }
//
// Calendar last_update_cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
// last_update_cal.setTimeInMillis(last_update_tstamp);
// long diff_in_ms = now.getTimeInMillis() - last_update_tstamp;
// long ms_today = now.get(Calendar.HOUR_OF_DAY) * 60 * 60 * 1000
// + now.get(Calendar.MINUTE) * 60 * 1000
// + now.get(Calendar.SECOND) * 1000
// + now.get(Calendar.MILLISECOND);
//
// return (now.get(Calendar.HOUR_OF_DAY) >= FIRST_UPDATE_HOUR
// && diff_in_ms > ms_today - FIRST_UPDATE_HOUR * 60 * 60 * 1000)
// ||
// (now.get(Calendar.HOUR_OF_DAY) >= SECOND_UPDATE_HOUR
// && diff_in_ms > ms_today - SECOND_UPDATE_HOUR * 60 * 60 * 1000);
// }
//
// public static boolean poemsFullFileExists(Context context) {
// File file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.FULL,
// PoemsLoader.FileType.CURRENT));
// File old_file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.FULL,
// PoemsLoader.FileType.PREV));
// return (file.exists() && file.length() > MIN_FILE_LENGTH) ||
// (old_file.exists() && old_file.length() > MIN_FILE_LENGTH);
// }
//
// public static boolean poems60DaysFileExists(Context context) {
// File file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.PARTIAL,
// PoemsLoader.FileType.CURRENT));
// File old_file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.PARTIAL,
// PoemsLoader.FileType.PREV));
// return (file.exists() && file.length() > 1) ||
// (old_file.exists() && old_file.length() > 1);
// }
//
// public static boolean isConnected(Context context) {
// ConnectivityManager cm =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//
// NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
// return activeNetwork != null &&
// activeNetwork.isConnected();
// }
//
// public static PoemsLoader.UpdateType getUpdateType(Calendar now, long last_full_update_tstamp) {
// if (now.getTimeInMillis() - last_full_update_tstamp >
// MAX_DAYS_BETWEEN_FULL_UPDATES * 24 * 60 * 60 * 1000) {
// return PoemsLoader.UpdateType.FULL;
// }
// return PoemsLoader.UpdateType.PARTIAL;
// }
// }
| import static org.junit.Assert.*;
import com.almoturg.sprog.data.UpdateHelpers;
import org.junit.Test;
import java.util.GregorianCalendar; | package com.almoturg.sprog;
public class UpdateHelpersTest {
@Test
public void isUpdateTimeTest(){
GregorianCalendar now;
long last_update;
long last_fcm;
now = new GregorianCalendar(2017, 1, 15, 14, 45);
last_update = new GregorianCalendar(2017, 1, 13, 13, 25).getTimeInMillis();
last_fcm = new GregorianCalendar(2017, 1, 14, 13, 17).getTimeInMillis(); | // Path: app/src/main/java/com/almoturg/sprog/data/UpdateHelpers.java
// public class UpdateHelpers {
// // These are the times when an update should be available on the server
// private static final int FIRST_UPDATE_HOUR = 2;
// private static final int SECOND_UPDATE_HOUR = 14;
// private static final long MIN_HOURS_BETWEEN_UPDATES = 11; // some margin if it runs faster
// private static final long MAX_DAYS_BETWEEN_LOADING_POEMS = 3;
// private static final long MAX_DAYS_BETWEEN_FULL_UPDATES = 30;
//
// // minimum length of poems.json file in bytes such that it is assumed to be complete
// // and therefore the cancel button is shown when updating
// private static final int MIN_FILE_LENGTH = 1000 * 1000;
//
// public static boolean isUpdateTime(Calendar now,
// long last_update_tstamp, long last_fcm_tstamp) {
// // Always load JSON when more than MAX_DAYS_BETWEEN_LOADING_POEMS days have passed
// // This is mainly to get updated scores/gold counts and to remove deleted poems.
// if (now.getTimeInMillis() - last_update_tstamp >
// MAX_DAYS_BETWEEN_LOADING_POEMS * 24 * 60 * 60 * 1000) {
// return true;
// }
//
// // last_fcm_tstamp is the time when the last FCM message was sent
// // if it showed that updates were available this function would not have been called
// if (now.getTimeInMillis() - last_fcm_tstamp < MIN_HOURS_BETWEEN_UPDATES * 60 * 60 * 1000) {
// return false;
// }
//
// Calendar last_update_cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
// last_update_cal.setTimeInMillis(last_update_tstamp);
// long diff_in_ms = now.getTimeInMillis() - last_update_tstamp;
// long ms_today = now.get(Calendar.HOUR_OF_DAY) * 60 * 60 * 1000
// + now.get(Calendar.MINUTE) * 60 * 1000
// + now.get(Calendar.SECOND) * 1000
// + now.get(Calendar.MILLISECOND);
//
// return (now.get(Calendar.HOUR_OF_DAY) >= FIRST_UPDATE_HOUR
// && diff_in_ms > ms_today - FIRST_UPDATE_HOUR * 60 * 60 * 1000)
// ||
// (now.get(Calendar.HOUR_OF_DAY) >= SECOND_UPDATE_HOUR
// && diff_in_ms > ms_today - SECOND_UPDATE_HOUR * 60 * 60 * 1000);
// }
//
// public static boolean poemsFullFileExists(Context context) {
// File file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.FULL,
// PoemsLoader.FileType.CURRENT));
// File old_file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.FULL,
// PoemsLoader.FileType.PREV));
// return (file.exists() && file.length() > MIN_FILE_LENGTH) ||
// (old_file.exists() && old_file.length() > MIN_FILE_LENGTH);
// }
//
// public static boolean poems60DaysFileExists(Context context) {
// File file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.PARTIAL,
// PoemsLoader.FileType.CURRENT));
// File old_file = new File(context.getExternalFilesDir(
// Environment.DIRECTORY_DOWNLOADS),
// PoemsLoader.getFilename(
// PoemsLoader.UpdateType.PARTIAL,
// PoemsLoader.FileType.PREV));
// return (file.exists() && file.length() > 1) ||
// (old_file.exists() && old_file.length() > 1);
// }
//
// public static boolean isConnected(Context context) {
// ConnectivityManager cm =
// (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//
// NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
// return activeNetwork != null &&
// activeNetwork.isConnected();
// }
//
// public static PoemsLoader.UpdateType getUpdateType(Calendar now, long last_full_update_tstamp) {
// if (now.getTimeInMillis() - last_full_update_tstamp >
// MAX_DAYS_BETWEEN_FULL_UPDATES * 24 * 60 * 60 * 1000) {
// return PoemsLoader.UpdateType.FULL;
// }
// return PoemsLoader.UpdateType.PARTIAL;
// }
// }
// Path: app/src/test/java/com/almoturg/sprog/UpdateHelpersTest.java
import static org.junit.Assert.*;
import com.almoturg.sprog.data.UpdateHelpers;
import org.junit.Test;
import java.util.GregorianCalendar;
package com.almoturg.sprog;
public class UpdateHelpersTest {
@Test
public void isUpdateTimeTest(){
GregorianCalendar now;
long last_update;
long last_fcm;
now = new GregorianCalendar(2017, 1, 15, 14, 45);
last_update = new GregorianCalendar(2017, 1, 13, 13, 25).getTimeInMillis();
last_fcm = new GregorianCalendar(2017, 1, 14, 13, 17).getTimeInMillis(); | assertEquals(true, UpdateHelpers.isUpdateTime(now, last_update, last_fcm)); |
PaulKlinger/Sprog-App | app/src/main/java/com/almoturg/sprog/view/PoemRow.java | // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
| import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme; | package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal; | // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// Path: app/src/main/java/com/almoturg/sprog/view/PoemRow.java
import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme;
package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal; | private static MarkdownConverter markdownConverter; |
PaulKlinger/Sprog-App | app/src/main/java/com/almoturg/sprog/view/PoemRow.java | // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
| import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme; | package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal;
private static MarkdownConverter markdownConverter;
| // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// Path: app/src/main/java/com/almoturg/sprog/view/PoemRow.java
import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme;
package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal;
private static MarkdownConverter markdownConverter;
| public static void update_poem_row_poem_page(Poem poem, View poem_row, |
PaulKlinger/Sprog-App | app/src/main/java/com/almoturg/sprog/view/PoemRow.java | // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
| import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme; | package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal;
private static MarkdownConverter markdownConverter;
public static void update_poem_row_poem_page(Poem poem, View poem_row,
Context context){
update_poem_row(poem, poem_row, true, false, false, false, context);
}
public static void update_poem_row_mainlist(Poem poem, View poem_row,
boolean show_only_favorites, boolean mark_read,
Context context){
update_poem_row(poem, poem_row, false, true, show_only_favorites, mark_read, context);
}
private static void update_poem_row(Poem poem, View poem_row, boolean border,
boolean main_list, boolean show_only_favorites,
boolean mark_read, Context context) {
if (cal == null) {
cal = Calendar.getInstance(Locale.ENGLISH);
}
if (markdownConverter == null) {
markdownConverter = new MarkdownConverter(context);
}
if (border) { | // Path: app/src/main/java/com/almoturg/sprog/data/MarkdownConverter.java
// public class MarkdownConverter {
// private static Bypass bypass;
// private static final Object bypassLock = new Object();
// private Context context;
//
// public MarkdownConverter(Context context){
// this.context = context;
// }
//
// public CharSequence convertPoemMarkdown(String markdown, double timestamp) {
// if (timestamp < 1360540800){ // = 2013-02-11
// // Sprog's early poems had paragraph breaks at the end of each line.
// // This regex replaces them with single linebreaks, except between stanzas.
// // (Stanza breaks are detected by checking if the line above is italicized (enclosed in
// // "*"s) while the one below is not, or vice versa. Some lines look like
// // "*lorem ipsum*," (punctuation after the closing "*").
// // There is a special case for one poem with "2." on a single line (c6juhtd).)
// markdown = markdown.replaceAll(
// "(?:(?<=(?<!\n)\\*[.,]?)\\n\\n(?=\\*))|(?:(?<!(?:\\*[.,]?)|(?:2\\.))\\n\\n(?!\\*))",
// " \n");
// }
// return convertMarkdown(markdown);
// }
//
// public CharSequence convertMarkdown(String markdown) {
// if (bypass == null) {
// synchronized (bypassLock) {
// bypass = new Bypass(context);
// }
// }
//
// markdown = markdown.replaceAll("(?:^|[^(\\[])(https?://\\S*\\.\\S*)(?:\\s|$)", "[$1]($1)");
//
// CharSequence converted;
// synchronized (bypassLock) {
// converted = bypass.markdownToSpannable(markdown);
// }
// return converted;
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/model/Poem.java
// public class Poem {
// public int silver;
// public int gold;
// public int platinum;
// public int score;
// public String content;
// public CharSequence first_line;
// public double timestamp;
// public long timestamp_long;
// public String post_title;
// public String post_author;
// public String post_content;
// public String post_url;
// public List<ParentComment> parents;
// public String link;
// public Poem main_poem;
// public boolean read;
// public boolean favorite;
//
// public Poem(int silver, int gold, int platinum, int score, String content,
// CharSequence first_line, double timestamp,
// String post_title, String post_author, String post_content, String post_url,
// List<ParentComment> parents, String link, Poem main_poem,
// boolean is_read, boolean is_favorite) {
// this.content = content;
// this.silver = silver;
// this.gold = gold;
// this.platinum = platinum;
// this.score = score;
// this.timestamp = timestamp;
// this.timestamp_long = (long) timestamp * 1000;
// this.post_title = post_title;
// this.post_author = post_author;
// this.post_content = post_content;
// this.post_url = post_url;
// this.parents = parents;
// this.link = link;
// this.main_poem = main_poem;
//
// this.first_line = first_line;
// this.read = is_read;
// this.favorite = is_favorite;
// }
//
// public void toggleFavorite(SprogDbHelper db){
// this.favorite = !this.favorite;
// if (this.favorite) {
// db.addFavoritePoem(this.link);
// } else {
// db.removeFavoritePoem(this.link);
// }
//
// }
//
// public int totalAwards(){
// return 3 * this.platinum + 2 * this.gold + this.silver;
// }
//
// public String getId() {
// return Util.last(this.link.split("/"));
// }
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static int getThemeColor(Context context, int attrId) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(attrId, value, true);
// return value.data;
// }
//
// Path: app/src/main/java/com/almoturg/sprog/util/Util.java
// public static boolean isDarkTheme(Context context) {
// final TypedValue value = new TypedValue();
// context.getTheme().resolveAttribute(R.attr.themeName, value, true);
// return value.string.equals("dark");
// }
// Path: app/src/main/java/com/almoturg/sprog/view/PoemRow.java
import android.content.Context;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.CardView;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.TextView;
import com.almoturg.sprog.R;
import com.almoturg.sprog.data.MarkdownConverter;
import com.almoturg.sprog.model.Poem;
import java.util.Calendar;
import java.util.Locale;
import static com.almoturg.sprog.util.Util.getThemeColor;
import static com.almoturg.sprog.util.Util.isDarkTheme;
package com.almoturg.sprog.view;
public class PoemRow {
private static Calendar cal;
private static MarkdownConverter markdownConverter;
public static void update_poem_row_poem_page(Poem poem, View poem_row,
Context context){
update_poem_row(poem, poem_row, true, false, false, false, context);
}
public static void update_poem_row_mainlist(Poem poem, View poem_row,
boolean show_only_favorites, boolean mark_read,
Context context){
update_poem_row(poem, poem_row, false, true, show_only_favorites, mark_read, context);
}
private static void update_poem_row(Poem poem, View poem_row, boolean border,
boolean main_list, boolean show_only_favorites,
boolean mark_read, Context context) {
if (cal == null) {
cal = Calendar.getInstance(Locale.ENGLISH);
}
if (markdownConverter == null) {
markdownConverter = new MarkdownConverter(context);
}
if (border) { | if (isDarkTheme(context)) { |
saiba/OpenBMLParser | test/src/saiba/bml/feedback/BMLBlockProgressFeedbackTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit tests for XMLBMLBlockProgressTest
* @author Herwin
*
*/
public class BMLBlockProgressFeedbackTest
{
private static final double PRECISION = 0.00001;
private FeedbackExtensionTests<BMLBlockProgressFeedback> fe = new FeedbackExtensionTests<BMLBlockProgressFeedback>();
BMLBlockProgressFeedback fb = new BMLBlockProgressFeedback();
@Test
public void testReadXML()
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/feedback/BMLBlockProgressFeedbackTest.java
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit tests for XMLBMLBlockProgressTest
* @author Herwin
*
*/
public class BMLBlockProgressFeedbackTest
{
private static final double PRECISION = 0.00001;
private FeedbackExtensionTests<BMLBlockProgressFeedback> fe = new FeedbackExtensionTests<BMLBlockProgressFeedback>();
BMLBlockProgressFeedback fb = new BMLBlockProgressFeedback();
@Test
public void testReadXML()
{ | String str = "<blockProgress " + TestUtil.getDefNS() + "id=\"bml1:start\" globalTime=\"10\" characterId=\"doctor\"/>"; |
saiba/OpenBMLParser | test/src/saiba/bml/core/GestureBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the GestureBehaviour
* @author welberge
*
*/
public class GestureBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/GestureBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the GestureBehaviour
* @author welberge
*
*/
public class GestureBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<gesture "+TestUtil.getDefNS()+"id=\"g1\" lexeme=\"BEAT\" " + extraAttributeString + "/>"; |
saiba/OpenBMLParser | test/src/saiba/bml/core/HeadDirectionShiftBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the HeadDirectionShiftBehaviour
* @author welberge
*
*/
public class HeadDirectionShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/HeadDirectionShiftBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the HeadDirectionShiftBehaviour
* @author welberge
*
*/
public class HeadDirectionShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<headDirectionShift "+TestUtil.getDefNS()+"id=\"head1\" target=\"bluebox\" " + |
saiba/OpenBMLParser | test/src/saiba/utils/TestUtil.java | // Path: src/saiba/bml/core/BMLElement.java
// public class BMLElement extends XMLStructureAdapter
// {
// public String id;
// public String getBmlId()
// {
// return "";
// }
//
//
// /*
// * The XML Stag for XML encoding
// */
// private static final String XMLTAG = "BMLStructureAdapter";
//
// /**
// * The XML Stag for XML encoding -- use this static method when you want to see if a given
// * String equals the xml tag for this class
// */
// public static String xmlTag()
// {
// return XMLTAG;
// }
//
// /**
// * The XML Stag for XML encoding -- use this method to find out the run-time xml tag of an
// * object
// */
// @Override
// public String getXMLTag()
// {
// return XMLTAG;
// }
//
// /**
// * Registers the (full) id of this BMLElement with the scheduler.
// */
// public void registerElementsById(BMLParser scheduler)
// {
// // Register this BMLElement.
// scheduler.registerBMLElement(this);
// }
//
// /**
// * Detects loops in decodeContent()-methods.
// */
// private int prevLine = -1;
//
// private int prevChar = -1;
//
// protected void ensureDecodeProgress(XMLTokenizer tokenizer)
// {
// int curLine = tokenizer.getLine();
// int curChar = tokenizer.getCharPos();
// if (curLine == prevLine && curChar == prevChar)
// {
// throw new XMLScanException(
// "Loop detected, no valid BML. Possibly, a STag was encountered that cannot be parsed. Line: "
// + curLine + ", char: " + curChar);
// }
// else
// {
// prevLine = curLine;
// prevChar = curChar;
// }
// }
//
// public static final String BMLNAMESPACE = "http://www.bml-initiative.org/bml/bml-1.0";
//
// @Override
// public String getNamespace()
// {
// return BMLNAMESPACE;
// }
// }
| import saiba.bml.core.BMLElement; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.utils;
/**
* Test utility functions
* @author Herwin
*/
public final class TestUtil
{
private TestUtil()
{
}
public static final String getDefNS()
{ | // Path: src/saiba/bml/core/BMLElement.java
// public class BMLElement extends XMLStructureAdapter
// {
// public String id;
// public String getBmlId()
// {
// return "";
// }
//
//
// /*
// * The XML Stag for XML encoding
// */
// private static final String XMLTAG = "BMLStructureAdapter";
//
// /**
// * The XML Stag for XML encoding -- use this static method when you want to see if a given
// * String equals the xml tag for this class
// */
// public static String xmlTag()
// {
// return XMLTAG;
// }
//
// /**
// * The XML Stag for XML encoding -- use this method to find out the run-time xml tag of an
// * object
// */
// @Override
// public String getXMLTag()
// {
// return XMLTAG;
// }
//
// /**
// * Registers the (full) id of this BMLElement with the scheduler.
// */
// public void registerElementsById(BMLParser scheduler)
// {
// // Register this BMLElement.
// scheduler.registerBMLElement(this);
// }
//
// /**
// * Detects loops in decodeContent()-methods.
// */
// private int prevLine = -1;
//
// private int prevChar = -1;
//
// protected void ensureDecodeProgress(XMLTokenizer tokenizer)
// {
// int curLine = tokenizer.getLine();
// int curChar = tokenizer.getCharPos();
// if (curLine == prevLine && curChar == prevChar)
// {
// throw new XMLScanException(
// "Loop detected, no valid BML. Possibly, a STag was encountered that cannot be parsed. Line: "
// + curLine + ", char: " + curChar);
// }
// else
// {
// prevLine = curLine;
// prevChar = curChar;
// }
// }
//
// public static final String BMLNAMESPACE = "http://www.bml-initiative.org/bml/bml-1.0";
//
// @Override
// public String getNamespace()
// {
// return BMLNAMESPACE;
// }
// }
// Path: test/src/saiba/utils/TestUtil.java
import saiba.bml.core.BMLElement;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.utils;
/**
* Test utility functions
* @author Herwin
*/
public final class TestUtil
{
private TestUtil()
{
}
public static final String getDefNS()
{ | return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" "; |
saiba/OpenBMLParser | test/src/saiba/bml/core/PostureShiftBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* unit tests for the PostureBehaviour
* @author welberge
*
*/
public class PostureShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/PostureShiftBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* unit tests for the PostureBehaviour
* @author welberge
*
*/
public class PostureShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<postureShift "+TestUtil.getDefNS()+" id=\"posture1\" " + extraAttributeString + ">" |
saiba/OpenBMLParser | test/src/saiba/bml/core/SpeechBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the SpeechBehaviour
* @author Herwin
*/
public class SpeechBehaviourTest extends AbstractBehaviourTest
{
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/SpeechBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the SpeechBehaviour
* @author Herwin
*/
public class SpeechBehaviourTest extends AbstractBehaviourTest
{
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<speech "+TestUtil.getDefNS()+"id=\"speech1\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/core/HeadBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the HeadBehaviour
* @author welberge
*
*/
public class HeadBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/HeadBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit tests for the HeadBehaviour
* @author welberge
*
*/
public class HeadBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<head "+TestUtil.getDefNS()+"id=\"head1\" lexeme=\"NOD\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/core/FaceLexemeBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the FaceLexemeBehaviour
* @author Herwin
*/
public class FaceLexemeBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/FaceLexemeBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the FaceLexemeBehaviour
* @author Herwin
*/
public class FaceLexemeBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<faceLexeme "+TestUtil.getDefNS()+"amount=\"0.25\" lexeme=\"lex1\" id=\"beh1\""+ |
saiba/OpenBMLParser | test/src/saiba/bml/core/PostureBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* unit tests for the PostureBehaviour
* @author welberge
*
*/
public class PostureBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/PostureBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* unit tests for the PostureBehaviour
* @author welberge
*
*/
public class PostureBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<posture "+TestUtil.getDefNS()+"id=\"posture1\" " + extraAttributeString + ">" |
saiba/OpenBMLParser | test/src/saiba/bml/core/LocomotionBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the locomotion behavior
* @author welberge
*/
public class LocomotionBehaviourTest extends AbstractBehaviourTest
{
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/LocomotionBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the locomotion behavior
* @author welberge
*/
public class LocomotionBehaviourTest extends AbstractBehaviourTest
{
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<locomotion "+TestUtil.getDefNS()+"id=\"loc1\" target=\"bluebox\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/feedback/BMLBlockPredictionFeedbackTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLScanException;
import java.io.IOException;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.Test;
import org.xml.sax.SAXException; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit testcases for the XMLBMLBlockPredictionFeedbackElementTest element
* @author hvanwelbergen
*
*/
public class BMLBlockPredictionFeedbackTest
{
private static final double PRECISION = 0.0001;
private BMLBlockPredictionFeedback fb = new BMLBlockPredictionFeedback();
private FeedbackExtensionTests<BMLBlockPredictionFeedback> fe = new FeedbackExtensionTests<BMLBlockPredictionFeedback>();
@Test
public void testReadXML()
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/feedback/BMLBlockPredictionFeedbackTest.java
import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLScanException;
import java.io.IOException;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.Test;
import org.xml.sax.SAXException;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit testcases for the XMLBMLBlockPredictionFeedbackElementTest element
* @author hvanwelbergen
*
*/
public class BMLBlockPredictionFeedbackTest
{
private static final double PRECISION = 0.0001;
private BMLBlockPredictionFeedback fb = new BMLBlockPredictionFeedback();
private FeedbackExtensionTests<BMLBlockPredictionFeedback> fe = new FeedbackExtensionTests<BMLBlockPredictionFeedback>();
@Test
public void testReadXML()
{ | String str = "<bml " + TestUtil.getDefNS() + " id=\"bml1\" globalStart=\"1\" globalEnd=\"2\"/>"; |
saiba/OpenBMLParser | src/saiba/bml/feedback/AbstractBMLFeedback.java | // Path: src/saiba/bml/core/CustomAttributeHandler.java
// public class CustomAttributeHandler
// {
// private Map<String, String> customStringAttributes = new HashMap<String, String>();
// private Map<String, Float> customFloatAttributes = new HashMap<String, Float>();
//
// public float getCustomFloatParameterValue(String name)
// {
// if (customFloatAttributes.containsKey(name))
// {
// return customFloatAttributes.get(name);
// }
// throw new IllegalArgumentException("Parameter " + name + " not found/not a float.");
// }
//
// public void addCustomStringParameterValue(String name, String value)
// {
// customStringAttributes.put(name, value);
// }
//
// public void addCustomFloatParameterValue(String name, float value)
// {
// customFloatAttributes.put(name, value);
// }
//
// public String getCustomStringParameterValue(String name)
// {
// if (customStringAttributes.containsKey(name))
// {
// return customStringAttributes.get(name);
// }
// return null;
// }
//
// public boolean specifiesCustomStringParameter(String name)
// {
// if (customStringAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean specifiesCustomFloatParameter(String name)
// {
// if (customFloatAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean specifiesCustomParameter(String name)
// {
// if (customStringAttributes.containsKey(name)) return true;
// if (customFloatAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean satisfiesCustomConstraint(String name, String value)
// {
// if (customStringAttributes.containsKey(name))
// {
// return customStringAttributes.get(name).equals(value);
// }
// return false;
// }
//
// public void decodeCustomAttributes(HashMap<String, String> attrMap, XMLTokenizer tokenizer, Set<String> floatAttributes,
// Set<String> stringAttributes, XMLStructureAdapter beh)
// {
// for (String attr : floatAttributes)
// {
// String value = beh.getOptionalAttribute(attr, attrMap);
// if (value != null)
// {
// customFloatAttributes.put(attr, Float.parseFloat(value));
// }
// }
//
// for (String attr : stringAttributes)
// {
// String value = beh.getOptionalAttribute(attr, attrMap);
// if (value != null)
// {
// customStringAttributes.put(attr, value);
// }
// }
// }
//
// public StringBuilder appendCustomAttributeString(StringBuilder buf, XMLFormatting fmt)
// {
// for (Entry<String, String> entries : customStringAttributes.entrySet())
// {
// String ns = entries.getKey().substring(0, entries.getKey().lastIndexOf(":"));
// String attr = entries.getKey().substring(entries.getKey().lastIndexOf(":") + 1);
// XMLStructureAdapter.appendNamespacedAttribute(buf, fmt, ns, attr, entries.getValue());
// }
//
// for (Entry<String, Float> entries : customFloatAttributes.entrySet())
// {
// String ns = entries.getKey().substring(0, entries.getKey().lastIndexOf(":"));
// String attr = entries.getKey().substring(entries.getKey().lastIndexOf(":") + 1);
// XMLStructureAdapter.appendNamespacedAttribute(buf, fmt, ns, attr, "" + entries.getValue());
// }
// return buf;
// }
// }
| import hmi.xml.XMLFormatting;
import hmi.xml.XMLNameSpace;
import hmi.xml.XMLStructureAdapter;
import hmi.xml.XMLTokenizer;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import saiba.bml.core.CustomAttributeHandler;
import com.google.common.collect.ImmutableList; | package saiba.bml.feedback;
/**
* Skeleton class for BMLFeedback
* @author herwinvw
*
*/
public class AbstractBMLFeedback extends XMLStructureAdapter implements BMLFeedback
{ | // Path: src/saiba/bml/core/CustomAttributeHandler.java
// public class CustomAttributeHandler
// {
// private Map<String, String> customStringAttributes = new HashMap<String, String>();
// private Map<String, Float> customFloatAttributes = new HashMap<String, Float>();
//
// public float getCustomFloatParameterValue(String name)
// {
// if (customFloatAttributes.containsKey(name))
// {
// return customFloatAttributes.get(name);
// }
// throw new IllegalArgumentException("Parameter " + name + " not found/not a float.");
// }
//
// public void addCustomStringParameterValue(String name, String value)
// {
// customStringAttributes.put(name, value);
// }
//
// public void addCustomFloatParameterValue(String name, float value)
// {
// customFloatAttributes.put(name, value);
// }
//
// public String getCustomStringParameterValue(String name)
// {
// if (customStringAttributes.containsKey(name))
// {
// return customStringAttributes.get(name);
// }
// return null;
// }
//
// public boolean specifiesCustomStringParameter(String name)
// {
// if (customStringAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean specifiesCustomFloatParameter(String name)
// {
// if (customFloatAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean specifiesCustomParameter(String name)
// {
// if (customStringAttributes.containsKey(name)) return true;
// if (customFloatAttributes.containsKey(name)) return true;
// return false;
// }
//
// public boolean satisfiesCustomConstraint(String name, String value)
// {
// if (customStringAttributes.containsKey(name))
// {
// return customStringAttributes.get(name).equals(value);
// }
// return false;
// }
//
// public void decodeCustomAttributes(HashMap<String, String> attrMap, XMLTokenizer tokenizer, Set<String> floatAttributes,
// Set<String> stringAttributes, XMLStructureAdapter beh)
// {
// for (String attr : floatAttributes)
// {
// String value = beh.getOptionalAttribute(attr, attrMap);
// if (value != null)
// {
// customFloatAttributes.put(attr, Float.parseFloat(value));
// }
// }
//
// for (String attr : stringAttributes)
// {
// String value = beh.getOptionalAttribute(attr, attrMap);
// if (value != null)
// {
// customStringAttributes.put(attr, value);
// }
// }
// }
//
// public StringBuilder appendCustomAttributeString(StringBuilder buf, XMLFormatting fmt)
// {
// for (Entry<String, String> entries : customStringAttributes.entrySet())
// {
// String ns = entries.getKey().substring(0, entries.getKey().lastIndexOf(":"));
// String attr = entries.getKey().substring(entries.getKey().lastIndexOf(":") + 1);
// XMLStructureAdapter.appendNamespacedAttribute(buf, fmt, ns, attr, entries.getValue());
// }
//
// for (Entry<String, Float> entries : customFloatAttributes.entrySet())
// {
// String ns = entries.getKey().substring(0, entries.getKey().lastIndexOf(":"));
// String attr = entries.getKey().substring(entries.getKey().lastIndexOf(":") + 1);
// XMLStructureAdapter.appendNamespacedAttribute(buf, fmt, ns, attr, "" + entries.getValue());
// }
// return buf;
// }
// }
// Path: src/saiba/bml/feedback/AbstractBMLFeedback.java
import hmi.xml.XMLFormatting;
import hmi.xml.XMLNameSpace;
import hmi.xml.XMLStructureAdapter;
import hmi.xml.XMLTokenizer;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import saiba.bml.core.CustomAttributeHandler;
import com.google.common.collect.ImmutableList;
package saiba.bml.feedback;
/**
* Skeleton class for BMLFeedback
* @author herwinvw
*
*/
public class AbstractBMLFeedback extends XMLStructureAdapter implements BMLFeedback
{ | protected CustomAttributeHandler caHandler = new CustomAttributeHandler(); |
saiba/OpenBMLParser | test/src/saiba/bml/core/GazeBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the GazeBehaviour
* @author Herwin
*/
public class GazeBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/GazeBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the GazeBehaviour
* @author Herwin
*/
public class GazeBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<gaze "+TestUtil.getDefNS()+"id=\"gaze1\" target=\"bluebox\" " + extraAttributeString + " influence=\"NECK\"/>"; |
saiba/OpenBMLParser | test/src/saiba/bml/core/RequiredTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import org.hamcrest.Matchers;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the required block
* @author welberge
*
*/
public class RequiredTest
{
private RequiredBlock reqBlock = new RequiredBlock("bml1");
@Test
public void testEmptyRequired()
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/RequiredTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import org.hamcrest.Matchers;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the required block
* @author welberge
*
*/
public class RequiredTest
{
private RequiredBlock reqBlock = new RequiredBlock("bml1");
@Test
public void testEmptyRequired()
{ | reqBlock.readXML("<required"+TestUtil.getDefNS()+"/>"); |
saiba/OpenBMLParser | test/src/saiba/bml/feedback/BMLWarningFeedbackTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* unit tests for XMLBMLWarning
* @author Herwin
*
*/
public class BMLWarningFeedbackTest
{
private FeedbackExtensionTests<BMLWarningFeedback> fe = new FeedbackExtensionTests<BMLWarningFeedback>();
private BMLWarningFeedback fb = new BMLWarningFeedback();
@Test
public void testReadXML()
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/feedback/BMLWarningFeedbackTest.java
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
import static org.junit.Assert.assertEquals;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* unit tests for XMLBMLWarning
* @author Herwin
*
*/
public class BMLWarningFeedbackTest
{
private FeedbackExtensionTests<BMLWarningFeedback> fe = new FeedbackExtensionTests<BMLWarningFeedback>();
private BMLWarningFeedback fb = new BMLWarningFeedback();
@Test
public void testReadXML()
{ | String str = "<warningFeedback " + TestUtil.getDefNS() |
saiba/OpenBMLParser | test/src/saiba/bml/feedback/BMLFeedbackParserTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit tests for the BMLFeedbackParser
* @author Herwin
*
*/
public class BMLFeedbackParserTest
{
@Test
public void testInvalid() throws IOException
{
assertNull(BMLFeedbackParser.parseFeedback("blah"));
}
private void assertFeedbackType(Class<?>feedbackType, String str) throws IOException
{
BMLFeedback fb = BMLFeedbackParser.parseFeedback(str);
assertThat(fb,instanceOf(feedbackType));
}
@Test
public void testBMLBlockProgressFeedback() throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/feedback/BMLFeedbackParserTest.java
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* Unit tests for the BMLFeedbackParser
* @author Herwin
*
*/
public class BMLFeedbackParserTest
{
@Test
public void testInvalid() throws IOException
{
assertNull(BMLFeedbackParser.parseFeedback("blah"));
}
private void assertFeedbackType(Class<?>feedbackType, String str) throws IOException
{
BMLFeedback fb = BMLFeedbackParser.parseFeedback(str);
assertThat(fb,instanceOf(feedbackType));
}
@Test
public void testBMLBlockProgressFeedback() throws IOException
{ | String str = "<blockProgress "+TestUtil.getDefNS()+ |
saiba/OpenBMLParser | test/src/saiba/bml/core/WaitBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the WaitBehavior
* @author Herwin
*/
public class WaitBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected WaitBehaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/WaitBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the WaitBehavior
* @author Herwin
*/
public class WaitBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected WaitBehaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<wait "+TestUtil.getDefNS()+" id=\"wait1\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/core/GazeShiftBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Test cases for the GazeShiftBehaviour
* @author welberge
*/
public class GazeShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/GazeShiftBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Test cases for the GazeShiftBehaviour
* @author welberge
*/
public class GazeShiftBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<gazeShift "+TestUtil.getDefNS()+"id=\"gaze1\" target=\"bluebox\" influence=\"NECK\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/core/PointingBehaviourTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the pointing behaviour
* @author Herwin
*
*/
public class PointingBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/core/PointingBehaviourTest.java
import static org.junit.Assert.assertEquals;
import hmi.xml.XMLTokenizer;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.core;
/**
* Unit test cases for the pointing behaviour
* @author Herwin
*
*/
public class PointingBehaviourTest extends AbstractBehaviourTest
{
private static final double PARAMETER_PRECISION = 0.0001;
@Override
protected Behaviour createBehaviour(String bmlId, String extraAttributeString) throws IOException
{ | String str = "<pointing "+TestUtil.getDefNS()+"id=\"point1\" target=\"bluebox\" " + |
saiba/OpenBMLParser | test/src/saiba/bml/feedback/BMLSyncPointProgressFeedbackTest.java | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil; | /*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* unit test cases for the XMLBMLSyncPointProgress
* @author Herwin
*/
public class BMLSyncPointProgressFeedbackTest
{
private static final double PRECISION = 0.00001;
private FeedbackExtensionTests<BMLSyncPointProgressFeedback> fe = new FeedbackExtensionTests<BMLSyncPointProgressFeedback>();
private BMLSyncPointProgressFeedback fb = new BMLSyncPointProgressFeedback();
@Test
public void testReadXML()
{ | // Path: test/src/saiba/utils/TestUtil.java
// public final class TestUtil
// {
// private TestUtil()
// {
// }
//
// public static final String getDefNS()
// {
// return " xmlns=\""+BMLElement.BMLNAMESPACE+"\" ";
// }
// }
// Path: test/src/saiba/bml/feedback/BMLSyncPointProgressFeedbackTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Test;
import saiba.utils.TestUtil;
/*******************************************************************************
* Copyright (c) 2013 University of Twente, Bielefeld University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package saiba.bml.feedback;
/**
* unit test cases for the XMLBMLSyncPointProgress
* @author Herwin
*/
public class BMLSyncPointProgressFeedbackTest
{
private static final double PRECISION = 0.00001;
private FeedbackExtensionTests<BMLSyncPointProgressFeedback> fe = new FeedbackExtensionTests<BMLSyncPointProgressFeedback>();
private BMLSyncPointProgressFeedback fb = new BMLSyncPointProgressFeedback();
@Test
public void testReadXML()
{ | String str = "<syncPointProgress " + TestUtil.getDefNS() |
marc-ashman/jrdp | jrdp/android/src/main/java/com/jrdp/client/android/AndroidCanvas.java | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
//
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RemoteDesktopApplication.java
// public interface RemoteDesktopApplication
// {
// public void onScreenDimensionsChanged(int width, int height);
// public void onRemoteDimensionsChanged(int width, int height);
// public void onCursorChanged(int deltaX, int deltaY);
// public void onCursorSet(int x, int y);
// public void onCursorLeftClick();
// public void onSpecialKeyboardKey(short key);
// public void onKeyboardKey(char key);
// public void onRequestRemoteViewRefresh();
// public void requestDisconnect(boolean askUser);
// }
| import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import com.jrdp.core.remote.rdp.Cursor;
import com.jrdp.core.remote.rdp.RemoteDesktopApplication; | /*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class AndroidCanvas extends BitmapDrawable implements com.jrdp.core.remote.Canvas
{ | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
//
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RemoteDesktopApplication.java
// public interface RemoteDesktopApplication
// {
// public void onScreenDimensionsChanged(int width, int height);
// public void onRemoteDimensionsChanged(int width, int height);
// public void onCursorChanged(int deltaX, int deltaY);
// public void onCursorSet(int x, int y);
// public void onCursorLeftClick();
// public void onSpecialKeyboardKey(short key);
// public void onKeyboardKey(char key);
// public void onRequestRemoteViewRefresh();
// public void requestDisconnect(boolean askUser);
// }
// Path: jrdp/android/src/main/java/com/jrdp/client/android/AndroidCanvas.java
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import com.jrdp.core.remote.rdp.Cursor;
import com.jrdp.core.remote.rdp.RemoteDesktopApplication;
/*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class AndroidCanvas extends BitmapDrawable implements com.jrdp.core.remote.Canvas
{ | private RemoteDesktopApplication app; |
marc-ashman/jrdp | jrdp/android/src/main/java/com/jrdp/client/android/AndroidCanvas.java | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
//
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RemoteDesktopApplication.java
// public interface RemoteDesktopApplication
// {
// public void onScreenDimensionsChanged(int width, int height);
// public void onRemoteDimensionsChanged(int width, int height);
// public void onCursorChanged(int deltaX, int deltaY);
// public void onCursorSet(int x, int y);
// public void onCursorLeftClick();
// public void onSpecialKeyboardKey(short key);
// public void onKeyboardKey(char key);
// public void onRequestRemoteViewRefresh();
// public void requestDisconnect(boolean askUser);
// }
| import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import com.jrdp.core.remote.rdp.Cursor;
import com.jrdp.core.remote.rdp.RemoteDesktopApplication; | /*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class AndroidCanvas extends BitmapDrawable implements com.jrdp.core.remote.Canvas
{
private RemoteDesktopApplication app;
//TODO: possible leak with activity here, change to handler
private Handler handler; | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
//
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RemoteDesktopApplication.java
// public interface RemoteDesktopApplication
// {
// public void onScreenDimensionsChanged(int width, int height);
// public void onRemoteDimensionsChanged(int width, int height);
// public void onCursorChanged(int deltaX, int deltaY);
// public void onCursorSet(int x, int y);
// public void onCursorLeftClick();
// public void onSpecialKeyboardKey(short key);
// public void onKeyboardKey(char key);
// public void onRequestRemoteViewRefresh();
// public void requestDisconnect(boolean askUser);
// }
// Path: jrdp/android/src/main/java/com/jrdp/client/android/AndroidCanvas.java
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import com.jrdp.core.remote.rdp.Cursor;
import com.jrdp.core.remote.rdp.RemoteDesktopApplication;
/*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class AndroidCanvas extends BitmapDrawable implements com.jrdp.core.remote.Canvas
{
private RemoteDesktopApplication app;
//TODO: possible leak with activity here, change to handler
private Handler handler; | private Cursor cursor; |
marc-ashman/jrdp | jrdp/android/src/main/java/com/jrdp/client/android/ConnectionListActivity.java | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
| import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.jrdp.core.util.Logger; | /*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class ConnectionListActivity extends Activity implements Storage.StorageListener
{
private ListView list;
private Button addNewConnectionButton;
private Button quickConnect;
private Storage storage;
@Override
public void onCreate(Bundle savedInstanceState)
{ | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
// Path: jrdp/android/src/main/java/com/jrdp/client/android/ConnectionListActivity.java
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.jrdp.core.util.Logger;
/*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.client.android;
public class ConnectionListActivity extends Activity implements Storage.StorageListener
{
private ListView list;
private Button addNewConnectionButton;
private Button quickConnect;
private Storage storage;
@Override
public void onCreate(Bundle savedInstanceState)
{ | Logger.setLogger(new AndroidLogger(AndroidLogger.LOG_LEVEL_DEBUG)); |
marc-ashman/jrdp | jrdp/core/src/main/java/com/jrdp/core/util/InputByteStream.java | // Path: jrdp/core/src/main/java/com/jrdp/core/encryption/EncryptionSession.java
// public interface EncryptionSession
// {
// public abstract byte[] encrypt(byte[] data, int offset, int length);
// public abstract byte[] decrypt(byte[] data, int offset, int length);
// public abstract byte[] createMac(byte[] data);
// }
| import com.jrdp.core.encryption.EncryptionSession; | public short getShortLittleEndian()
{
return (short) ((data[pos++] & 0xFF) | (data[pos++] & 0xFF) << 8);
}
public short[] getShortArray(int size)
{
short[] array = new short[size];
for(int i=0; i < size; i++)
{
array[i] = getShort();
}
return array;
}
public short[] getShortArrayLittleEndian(int size)
{
short[] array = new short[size];
for(int i=0; i < size; i++)
{
array[i] = getShortLittleEndian();
}
return array;
}
public int left()
{
return data.length - pos;
}
| // Path: jrdp/core/src/main/java/com/jrdp/core/encryption/EncryptionSession.java
// public interface EncryptionSession
// {
// public abstract byte[] encrypt(byte[] data, int offset, int length);
// public abstract byte[] decrypt(byte[] data, int offset, int length);
// public abstract byte[] createMac(byte[] data);
// }
// Path: jrdp/core/src/main/java/com/jrdp/core/util/InputByteStream.java
import com.jrdp.core.encryption.EncryptionSession;
public short getShortLittleEndian()
{
return (short) ((data[pos++] & 0xFF) | (data[pos++] & 0xFF) << 8);
}
public short[] getShortArray(int size)
{
short[] array = new short[size];
for(int i=0; i < size; i++)
{
array[i] = getShort();
}
return array;
}
public short[] getShortArrayLittleEndian(int size)
{
short[] array = new short[size];
for(int i=0; i < size; i++)
{
array[i] = getShortLittleEndian();
}
return array;
}
public int left()
{
return data.length - pos;
}
| public void decryptStream(EncryptionSession encryption) |
marc-ashman/jrdp | jrdp/core/src/main/java/com/jrdp/core/remote/Canvas.java | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
| import com.jrdp.core.remote.rdp.Cursor; | /*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.core.remote;
public interface Canvas
{
public void setCanvasBottomUp(int[] img, int width, int height, int x,
int y, int clippingWidth, int clippingHeight);
public void setCanvas(int[] img, int width, int height, int x, int y,
int clippingWidth, int clippingHeight);
public void cursorPositionChanged(int x, int y); | // Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/Cursor.java
// public class Cursor
// {
// private int [] img;
// private short width;
// private short height;
// private short hotspotX;
// private short hotspotY;
//
// public Cursor(int[] img, short width, short height, short hotspotX, short hotspotY)
// {
// this.img = img;
// this.width = width;
// this.height = height;
// this.hotspotX = hotspotX;
// this.hotspotY = hotspotY;
// }
//
// public int[] getCursorBitmap()
// {
// return img;
// }
//
// public short getWidth()
// {
// return width;
// }
//
// public short getHeight()
// {
// return height;
// }
//
// public short getHotspotX()
// {
// return hotspotX;
// }
//
// public short getHotspotY()
// {
// return hotspotY;
// }
// }
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/Canvas.java
import com.jrdp.core.remote.rdp.Cursor;
/*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.core.remote;
public interface Canvas
{
public void setCanvasBottomUp(int[] img, int width, int height, int x,
int y, int clippingWidth, int clippingHeight);
public void setCanvas(int[] img, int width, int height, int x, int y,
int clippingWidth, int clippingHeight);
public void cursorPositionChanged(int x, int y); | public void setCursor(Cursor cursor); |
marc-ashman/jrdp | jrdp/android/src/main/java/com/jrdp/client/android/ConnectionSettingsActivity.java | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
| import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.jrdp.core.util.Logger;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText; | uri.query(connectionId + "");
Intent intent = new Intent(ConnectionSettingsActivity.this, RemoteDesktopActivity.class);
intent.setData(uri.build());
this.startActivity(intent);
}
private void save()
{
ContentValues settings = new ContentValues();
settings.put(Storage.ROW_NICKNAME, "Nickname Placeholder");
settings.put(Storage.ROW_IP, server.getText().toString());
settings.put(Storage.ROW_PORT, port.getText().toString());
settings.put(Storage.ROW_USERNAME, username.getText().toString());
settings.put(Storage.ROW_PASSWORD, password.getText().toString());
settings.put(Storage.ROW_DOMAIN, domain.getText().toString());
settings.put(Storage.ROW_ENCRYPTION_LEVEL, encryption.getSelectedItemPosition());
settings.put(Storage.ROW_PERFORMANCE_FLAGS, 1);
settings.put(Storage.ROW_RESOLUTION_INDEX, resolution.getSelectedItemPosition());
settings.put(Storage.ROW_COLOR, colorDepth.getSelectedItemPosition());
settings.put(Storage.ROW_INPUT_TYPE, 2);
//TODO: implement ordering of connection list
settings.put(Storage.ROW_LIST_ORDER, 1);
if(isNew)
{
connectionId = String.valueOf(storage.insert(Storage.TABLE_CONNECTION_INFO, settings));
isNew = false;
}
else
storage.updateData(Storage.TABLE_CONNECTION_INFO, settings, Storage.ROW_ID + "=" + connectionId); | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
// Path: jrdp/android/src/main/java/com/jrdp/client/android/ConnectionSettingsActivity.java
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.jrdp.core.util.Logger;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
uri.query(connectionId + "");
Intent intent = new Intent(ConnectionSettingsActivity.this, RemoteDesktopActivity.class);
intent.setData(uri.build());
this.startActivity(intent);
}
private void save()
{
ContentValues settings = new ContentValues();
settings.put(Storage.ROW_NICKNAME, "Nickname Placeholder");
settings.put(Storage.ROW_IP, server.getText().toString());
settings.put(Storage.ROW_PORT, port.getText().toString());
settings.put(Storage.ROW_USERNAME, username.getText().toString());
settings.put(Storage.ROW_PASSWORD, password.getText().toString());
settings.put(Storage.ROW_DOMAIN, domain.getText().toString());
settings.put(Storage.ROW_ENCRYPTION_LEVEL, encryption.getSelectedItemPosition());
settings.put(Storage.ROW_PERFORMANCE_FLAGS, 1);
settings.put(Storage.ROW_RESOLUTION_INDEX, resolution.getSelectedItemPosition());
settings.put(Storage.ROW_COLOR, colorDepth.getSelectedItemPosition());
settings.put(Storage.ROW_INPUT_TYPE, 2);
//TODO: implement ordering of connection list
settings.put(Storage.ROW_LIST_ORDER, 1);
if(isNew)
{
connectionId = String.valueOf(storage.insert(Storage.TABLE_CONNECTION_INFO, settings));
isNew = false;
}
else
storage.updateData(Storage.TABLE_CONNECTION_INFO, settings, Storage.ROW_ID + "=" + connectionId); | Logger.log("saved new connection under id: " + connectionId); |
marc-ashman/jrdp | jrdp/android/src/main/java/com/jrdp/client/android/Storage.java | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
| import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import com.jrdp.core.util.Logger;
import java.util.Vector; |
private class DatabaseHelper extends SQLiteOpenHelper
{
public DatabaseHelper(Context context, String name, CursorFactory factory, int version)
{
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL("CREATE TABLE " + TABLE_CONNECTION_INFO + " (" +
ROW_ID + " INTEGER PRIMARY KEY," +
ROW_NICKNAME + " TEXT," +
ROW_IP + " TEXT," +
ROW_PORT + " INTEGER," +
ROW_USERNAME + " TEXT," +
ROW_PASSWORD + " TEXT," +
ROW_DOMAIN + " TEXT," +
ROW_ENCRYPTION_LEVEL + " INTEGER," +
ROW_PERFORMANCE_FLAGS + " INTEGER," +
ROW_RESOLUTION_INDEX + " INTEGER," +
ROW_COLOR + " INTEGER," +
ROW_INPUT_TYPE + " INTEGER," +
ROW_LIST_ORDER + " INTEGER );");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{ | // Path: jrdp/core/src/main/java/com/jrdp/core/util/Logger.java
// public class Logger
// {
// public static final int INFO = 0;
// public static final int DEBUG = 1;
// public static final int ERROR = 2;
// private static LoggerInterface logger;
//
// public static void setLogger(LoggerInterface newLogger)
// {
// logger = newLogger;
// }
//
// public static void log(int type, String message)
// {
// if(logger != null)
// logger.log(type, message);
// }
//
// public static void log(String message)
// {
// if(logger != null)
// logger.log(message);
// }
//
// public static void log(Exception e)
// {
// if(logger != null)
// logger.log(e);
// }
//
// public static void log(Exception e, String message)
// {
// if(logger != null)
// logger.log(e, message);
// }
//
// public interface LoggerInterface
// {
// public void log(int type, String message);
// public void log(String message);
// public void log(Exception e);
// public void log(Exception e, String message);
// }
// }
// Path: jrdp/android/src/main/java/com/jrdp/client/android/Storage.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import com.jrdp.core.util.Logger;
import java.util.Vector;
private class DatabaseHelper extends SQLiteOpenHelper
{
public DatabaseHelper(Context context, String name, CursorFactory factory, int version)
{
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL("CREATE TABLE " + TABLE_CONNECTION_INFO + " (" +
ROW_ID + " INTEGER PRIMARY KEY," +
ROW_NICKNAME + " TEXT," +
ROW_IP + " TEXT," +
ROW_PORT + " INTEGER," +
ROW_USERNAME + " TEXT," +
ROW_PASSWORD + " TEXT," +
ROW_DOMAIN + " TEXT," +
ROW_ENCRYPTION_LEVEL + " INTEGER," +
ROW_PERFORMANCE_FLAGS + " INTEGER," +
ROW_RESOLUTION_INDEX + " INTEGER," +
ROW_COLOR + " INTEGER," +
ROW_INPUT_TYPE + " INTEGER," +
ROW_LIST_ORDER + " INTEGER );");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{ | Logger.log(Logger.INFO, "Upgrading database from " + oldVersion + " to " + newVersion); |
marc-ashman/jrdp | jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RdpPacket.java | // Path: jrdp/core/src/main/java/com/jrdp/core/encryption/EncryptionSession.java
// public interface EncryptionSession
// {
// public abstract byte[] encrypt(byte[] data, int offset, int length);
// public abstract byte[] decrypt(byte[] data, int offset, int length);
// public abstract byte[] createMac(byte[] data);
// }
| import com.jrdp.core.encryption.EncryptionSession;
import java.util.Vector; | /*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.core.remote.rdp;
class RdpPacket
{
private Vector<PacketPeice> peices;
private int length;
public RdpPacket()
{
peices = new Vector<PacketPeice>();
}
public void addPacketPeiceAtEnd(byte[] peice)
{
addPacketPeiceAtEnd(peice, null);
}
| // Path: jrdp/core/src/main/java/com/jrdp/core/encryption/EncryptionSession.java
// public interface EncryptionSession
// {
// public abstract byte[] encrypt(byte[] data, int offset, int length);
// public abstract byte[] decrypt(byte[] data, int offset, int length);
// public abstract byte[] createMac(byte[] data);
// }
// Path: jrdp/core/src/main/java/com/jrdp/core/remote/rdp/RdpPacket.java
import com.jrdp.core.encryption.EncryptionSession;
import java.util.Vector;
/*
* Copyright (C) 2013 JRDP Project
*
* 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.jrdp.core.remote.rdp;
class RdpPacket
{
private Vector<PacketPeice> peices;
private int length;
public RdpPacket()
{
peices = new Vector<PacketPeice>();
}
public void addPacketPeiceAtEnd(byte[] peice)
{
addPacketPeiceAtEnd(peice, null);
}
| public void addPacketPeiceAtEnd(byte[] peice, EncryptionSession crypto) |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/ConsoleSink.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
| import java.util.Map;
import com.presidentio.testdatagenerator.model.Template; | /**
* 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.presidentio.testdatagenerator.output;
/**
* Created by Vitaliy on 23.01.2015.
*/
public class ConsoleSink implements Sink {
@Override
public void init(Map<String, String> props) {
if (!props.isEmpty()) {
throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + props);
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/ConsoleSink.java
import java.util.Map;
import com.presidentio.testdatagenerator.model.Template;
/**
* 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.presidentio.testdatagenerator.output;
/**
* Created by Vitaliy on 23.01.2015.
*/
public class ConsoleSink implements Sink {
@Override
public void init(Map<String, String> props) {
if (!props.isEmpty()) {
throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + props);
}
}
@Override | public void process(Template template, Map<String, Object> map) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/path/ConstPathProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Template;
import java.util.Map; | package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public class ConstPathProvider implements PathProvider {
private String filePath;
@Override
public void init(Map<String, String> props) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/path/ConstPathProvider.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Template;
import java.util.Map;
package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public class ConstPathProvider implements PathProvider {
private String filePath;
@Override
public void init(Map<String, String> props) { | filePath = props.get(PropConst.FILE); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/path/ConstPathProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Template;
import java.util.Map; | package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public class ConstPathProvider implements PathProvider {
private String filePath;
@Override
public void init(Map<String, String> props) {
filePath = props.get(PropConst.FILE);
if (filePath == null) {
throw new IllegalArgumentException(PropConst.FILE + " does not specified or null");
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/path/ConstPathProvider.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Template;
import java.util.Map;
package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public class ConstPathProvider implements PathProvider {
private String filePath;
@Override
public void init(Map<String, String> props) {
filePath = props.get(PropConst.FILE);
if (filePath == null) {
throw new IllegalArgumentException(PropConst.FILE + " does not specified or null");
}
}
@Override | public String getFilePath(Template template, Map<String, Object> map) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
| import com.presidentio.testdatagenerator.model.Schema;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.deser.StdDeserializerProvider;
import org.codehaus.jackson.map.module.SimpleDeserializers;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; | /**
* 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.presidentio.testdatagenerator.parser;
public class JsonSchemaSerializer implements SchemaSerializer {
private ObjectMapper objectMapper;
public JsonSchemaSerializer() {
objectMapper = new ObjectMapper();
SimpleDeserializers simpleDeserializers = new SimpleDeserializers();
simpleDeserializers.addDeserializer(String.class, new StringDeserializer());
objectMapper.setDeserializerProvider(
new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers));
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/parser/JsonSchemaSerializer.java
import com.presidentio.testdatagenerator.model.Schema;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.deser.StdDeserializerProvider;
import org.codehaus.jackson.map.module.SimpleDeserializers;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 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.presidentio.testdatagenerator.parser;
public class JsonSchemaSerializer implements SchemaSerializer {
private ObjectMapper objectMapper;
public JsonSchemaSerializer() {
objectMapper = new ObjectMapper();
SimpleDeserializers simpleDeserializers = new SimpleDeserializers();
simpleDeserializers.addDeserializer(String.class, new StringDeserializer());
objectMapper.setDeserializerProvider(
new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers));
}
@Override | public Schema deserialize(InputStream inputStream) throws IOException { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst; | /**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst;
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) { | if (props.containsKey(PropConst.OP)) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst; | /**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) {
if (props.containsKey(PropConst.OP)) {
op = props.get(PropConst.OP);
}
var = props.get(PropConst.VAR);
if (var == null) {
throw new IllegalArgumentException("Var does not specified or null");
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst;
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) {
if (props.containsKey(PropConst.OP)) {
op = props.get(PropConst.OP);
}
var = props.get(PropConst.VAR);
if (var == null) {
throw new IllegalArgumentException("Var does not specified or null");
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst; | /**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) {
if (props.containsKey(PropConst.OP)) {
op = props.get(PropConst.OP);
}
var = props.get(PropConst.VAR);
if (var == null) {
throw new IllegalArgumentException("Var does not specified or null");
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/CounterProvider.java
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.PropConst;
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator.provider;
public class CounterProvider implements ValueProvider {
public static final String INC = "++";
public static final String DEC = "--";
public static final String EQ = "==";
private String var;
private String op = "++";
@Override
public void init(Map<String, String> props) {
if (props.containsKey(PropConst.OP)) {
op = props.get(PropConst.OP);
}
var = props.get(PropConst.VAR);
if (var == null) {
throw new IllegalArgumentException("Var does not specified or null");
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
| // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
| private Context context; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context; | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context; | private ValueProvider valueProvider; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider; | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider; | private Field field; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>(); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>(); | props.put(PropConst.DEPTH, "3"); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>();
props.put(PropConst.DEPTH, "3");
props.put(PropConst.FIELD, "id"); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>();
props.put(PropConst.DEPTH, "3");
props.put(PropConst.FIELD, "id"); | valueProvider = new ParentProvider(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>();
props.put(PropConst.DEPTH, "3");
props.put(PropConst.FIELD, "id");
valueProvider = new ParentProvider();
valueProvider.init(props);
context = new Context(new Context(new Context(new Context(null, null, null), Collections.<String, Object>singletonMap("id", "123")), new HashMap<String, Object>()), new HashMap<String, Object>()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ParentProvider.java
// public class ParentProvider implements ValueProvider {
//
// private int depth = 1;
//
// private String field;
//
// @Override
// public void init(Map<String, String> props) {
// if (props.containsKey(PropConst.DEPTH)) {
// depth = Integer.valueOf(props.get(PropConst.DEPTH));
// }
// field = props.get(PropConst.FIELD);
// if (field == null) {
// throw new IllegalArgumentException("Field does not specified or null");
// }
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Parent parent = context.getParent();
// for (int i = 1; i < depth; i++) {
// parent = parent.getParent();
// }
// return TypeConverter.convert(parent.get(this.field).toString(), field.getType());
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ParentBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ParentProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ParentBenchmark {
private Context context;
private ValueProvider valueProvider;
private Field field;
@Setup
public void init() {
Map<String, String> props = new HashMap<>();
props.put(PropConst.DEPTH, "3");
props.put(PropConst.FIELD, "id");
valueProvider = new ParentProvider();
valueProvider.init(props);
context = new Context(new Context(new Context(new Context(null, null, null), Collections.<String, Object>singletonMap("id", "123")), new HashMap<String, Object>()), new HashMap<String, Object>()); | field = new Field("testField", TypeConst.STRING, null); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/DefaultValueProviderFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/ValueProviderNameConst.java
// public class ValueProviderNameConst {
//
// public static final String CONST = "const";
// public static final String EXPR = "expr";
// public static final String EMAIL = "email";
// public static final String RANDOM = "random";
// public static final String SELECT = "select";
// public static final String PEOPLE_NAME = "people-name";
// public static final String COUNTRY = "country";
// public static final String PARENT = "parent";
// public static final String COUNTER = "counter";
// public static final String TIME = "time";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java
// public class Provider {
//
// private String name;
//
// private HashMap<String, String> props;
//
// public Provider() {
// }
//
// public Provider(String name, HashMap<String, String> props) {
// this.name = name;
// this.props = props;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public HashMap<String, String> getProps() {
// return props;
// }
//
// public void setProps(HashMap<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.model.Provider;
import java.util.HashMap;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.ValueProviderNameConst; | /**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.presidentio.testdatagenerator.provider;
public class DefaultValueProviderFactory implements ValueProviderFactory {
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/ValueProviderNameConst.java
// public class ValueProviderNameConst {
//
// public static final String CONST = "const";
// public static final String EXPR = "expr";
// public static final String EMAIL = "email";
// public static final String RANDOM = "random";
// public static final String SELECT = "select";
// public static final String PEOPLE_NAME = "people-name";
// public static final String COUNTRY = "country";
// public static final String PARENT = "parent";
// public static final String COUNTER = "counter";
// public static final String TIME = "time";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java
// public class Provider {
//
// private String name;
//
// private HashMap<String, String> props;
//
// public Provider() {
// }
//
// public Provider(String name, HashMap<String, String> props) {
// this.name = name;
// this.props = props;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public HashMap<String, String> getProps() {
// return props;
// }
//
// public void setProps(HashMap<String, String> props) {
// this.props = props;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/DefaultValueProviderFactory.java
import com.presidentio.testdatagenerator.model.Provider;
import java.util.HashMap;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.ValueProviderNameConst;
/**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.presidentio.testdatagenerator.provider;
public class DefaultValueProviderFactory implements ValueProviderFactory {
@Override | public ValueProvider buildValueProvider(Provider provider) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/DefaultValueProviderFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/ValueProviderNameConst.java
// public class ValueProviderNameConst {
//
// public static final String CONST = "const";
// public static final String EXPR = "expr";
// public static final String EMAIL = "email";
// public static final String RANDOM = "random";
// public static final String SELECT = "select";
// public static final String PEOPLE_NAME = "people-name";
// public static final String COUNTRY = "country";
// public static final String PARENT = "parent";
// public static final String COUNTER = "counter";
// public static final String TIME = "time";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java
// public class Provider {
//
// private String name;
//
// private HashMap<String, String> props;
//
// public Provider() {
// }
//
// public Provider(String name, HashMap<String, String> props) {
// this.name = name;
// this.props = props;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public HashMap<String, String> getProps() {
// return props;
// }
//
// public void setProps(HashMap<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.model.Provider;
import java.util.HashMap;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.ValueProviderNameConst; | /**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.presidentio.testdatagenerator.provider;
public class DefaultValueProviderFactory implements ValueProviderFactory {
@Override
public ValueProvider buildValueProvider(Provider provider) {
Map<String, String> props = new HashMap<>();
if (provider.getProps() != null) {
props = new HashMap<>(provider.getProps());
}
ValueProvider valueProvider;
switch (provider.getName()) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/ValueProviderNameConst.java
// public class ValueProviderNameConst {
//
// public static final String CONST = "const";
// public static final String EXPR = "expr";
// public static final String EMAIL = "email";
// public static final String RANDOM = "random";
// public static final String SELECT = "select";
// public static final String PEOPLE_NAME = "people-name";
// public static final String COUNTRY = "country";
// public static final String PARENT = "parent";
// public static final String COUNTER = "counter";
// public static final String TIME = "time";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Provider.java
// public class Provider {
//
// private String name;
//
// private HashMap<String, String> props;
//
// public Provider() {
// }
//
// public Provider(String name, HashMap<String, String> props) {
// this.name = name;
// this.props = props;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public HashMap<String, String> getProps() {
// return props;
// }
//
// public void setProps(HashMap<String, String> props) {
// this.props = props;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/DefaultValueProviderFactory.java
import com.presidentio.testdatagenerator.model.Provider;
import java.util.HashMap;
import java.util.Map;
import com.presidentio.testdatagenerator.cons.ValueProviderNameConst;
/**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.presidentio.testdatagenerator.provider;
public class DefaultValueProviderFactory implements ValueProviderFactory {
@Override
public ValueProvider buildValueProvider(Provider provider) {
Map<String, String> props = new HashMap<>();
if (provider.getProps() != null) {
props = new HashMap<>(provider.getProps());
}
ValueProvider valueProvider;
switch (provider.getName()) { | case ValueProviderNameConst.CONST: |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.context.Context; | /**
* 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.presidentio.testdatagenerator.provider;
public interface ValueProvider {
void init(Map<String, String> props);
| // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.context.Context;
/**
* 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.presidentio.testdatagenerator.provider;
public interface ValueProvider {
void init(Map<String, String> props);
| Object nextValue(Context context, Field field); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.context.Context; | /**
* 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.presidentio.testdatagenerator.provider;
public interface ValueProvider {
void init(Map<String, String> props);
| // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
import com.presidentio.testdatagenerator.model.Field;
import java.util.Map;
import com.presidentio.testdatagenerator.context.Context;
/**
* 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.presidentio.testdatagenerator.provider;
public interface ValueProvider {
void init(Map<String, String> props);
| Object nextValue(Context context, Field field); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map; | /**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain"; | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain"; | props.put(PropConst.DOMAIN, propDomain); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map; | /**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | Object result = emailProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null)); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map; | /**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | Object result = emailProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null)); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map; | /**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/EmailProviderTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 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.presidentio.testdatagenerator.provider;
public class EmailProviderTest {
@Test
public void testNextValueWithSpecifiedDomain() throws Exception {
Map<String, String> props = new HashMap<>();
String propDomain = "test.domain";
props.put(PropConst.DOMAIN, propDomain);
EmailProvider emailProvider = new EmailProvider();
emailProvider.init(props); | Object result = emailProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null)); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception { | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java
import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception { | SchemaBuilder schemaBuilder = new SchemaBuilder(); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : getSchemaResource()) {
schemaBuilder.fromResource(resource);
} | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java
import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : getSchemaResource()) {
schemaBuilder.fromResource(resource);
} | Schema schema = schemaBuilder.build(); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : getSchemaResource()) {
schemaBuilder.fromResource(resource);
}
Schema schema = schemaBuilder.build();
OneTimeGenerator generator = buildGenerator();
generator.generate(schema);
testResult(schema.getOutput());
}
| // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/test/java/com/presidentio/testdatagenerator/AbstractGeneratorTest.java
import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.junit.Test;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public abstract class AbstractGeneratorTest {
protected abstract List<String> getSchemaResource();
protected OneTimeGenerator buildGenerator() {
return new OneTimeGenerator();
}
@Test
public void testGenerate() throws Exception {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : getSchemaResource()) {
schemaBuilder.fromResource(resource);
}
Schema schema = schemaBuilder.build();
OneTimeGenerator generator = buildGenerator();
generator.generate(schema);
testResult(schema.getOutput());
}
| protected abstract void testResult(Output output); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/path/PathProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
| import com.presidentio.testdatagenerator.model.Template;
import java.util.Map; | package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public interface PathProvider {
void init(Map<String, String> props);
| // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/path/PathProvider.java
import com.presidentio.testdatagenerator.model.Template;
import java.util.Map;
package com.presidentio.testdatagenerator.output.path;
/**
* Created by presidentio on 24.04.15.
*/
public interface PathProvider {
void init(Map<String, String> props);
| String getFilePath(Template template, Map<String, Object> map); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/PeopleNameValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class PeopleNameValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new PeopleNameProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/SqlFileTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public class SqlFileTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-file-schema.json");
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/SqlFileTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public class SqlFileTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-file-schema.json");
}
@Override | protected void testResult(Output output) { |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/SqlFileTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public class SqlFileTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-file-schema.json");
}
@Override
protected void testResult(Output output) {
try { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/SqlFileTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public class SqlFileTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-file-schema.json");
}
@Override
protected void testResult(Output output) {
try { | executeSqlFile(output.getProps().get(PropConst.FILE)); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /**
* 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.presidentio.testdatagenerator.provider;
public class ExpressionProxyProvider implements ValueProvider {
private static final Pattern PARENT_EXP = Pattern.compile("(parent\\.)+(\\w+)");
private static final Pattern COUNTER_INC = Pattern.compile("(\\w+)\\+\\+");
private String expr;
private ValueProvider valueProvider;
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 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.presidentio.testdatagenerator.provider;
public class ExpressionProxyProvider implements ValueProvider {
private static final Pattern PARENT_EXP = Pattern.compile("(parent\\.)+(\\w+)");
private static final Pattern COUNTER_INC = Pattern.compile("(\\w+)\\+\\+");
private String expr;
private ValueProvider valueProvider;
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props); | expr = propsCopy.remove(PropConst.EXPR); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern; |
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props);
expr = propsCopy.remove(PropConst.EXPR);
if (expr == null) {
throw new IllegalArgumentException("Value does not specified or null");
}
Matcher matcher = PARENT_EXP.matcher(expr);
if (matcher.matches()) {
valueProvider = new ParentProvider();
Map<String, String> params = new HashMap<>(2);
params.put(PropConst.DEPTH, "" + countOccurrence(expr, '.'));
params.put(PropConst.FIELD, matcher.group(2));
valueProvider.init(params);
} else {
matcher = COUNTER_INC.matcher(expr);
if (matcher.matches()) {
Map<String, String> params = new HashMap<>(1);
params.put(PropConst.VAR, matcher.group(1));
valueProvider = new CounterProvider();
valueProvider.init(params);
} else {
valueProvider = new ExpressionProvider();
valueProvider.init(props);
}
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props);
expr = propsCopy.remove(PropConst.EXPR);
if (expr == null) {
throw new IllegalArgumentException("Value does not specified or null");
}
Matcher matcher = PARENT_EXP.matcher(expr);
if (matcher.matches()) {
valueProvider = new ParentProvider();
Map<String, String> params = new HashMap<>(2);
params.put(PropConst.DEPTH, "" + countOccurrence(expr, '.'));
params.put(PropConst.FIELD, matcher.group(2));
valueProvider.init(params);
} else {
matcher = COUNTER_INC.matcher(expr);
if (matcher.matches()) {
Map<String, String> params = new HashMap<>(1);
params.put(PropConst.VAR, matcher.group(1));
valueProvider = new CounterProvider();
valueProvider.init(params);
} else {
valueProvider = new ExpressionProvider();
valueProvider.init(props);
}
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern; |
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props);
expr = propsCopy.remove(PropConst.EXPR);
if (expr == null) {
throw new IllegalArgumentException("Value does not specified or null");
}
Matcher matcher = PARENT_EXP.matcher(expr);
if (matcher.matches()) {
valueProvider = new ParentProvider();
Map<String, String> params = new HashMap<>(2);
params.put(PropConst.DEPTH, "" + countOccurrence(expr, '.'));
params.put(PropConst.FIELD, matcher.group(2));
valueProvider.init(params);
} else {
matcher = COUNTER_INC.matcher(expr);
if (matcher.matches()) {
Map<String, String> params = new HashMap<>(1);
params.put(PropConst.VAR, matcher.group(1));
valueProvider = new CounterProvider();
valueProvider.init(params);
} else {
valueProvider = new ExpressionProvider();
valueProvider.init(props);
}
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProxyProvider.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Override
public void init(Map<String, String> props) {
Map<String, String> propsCopy = new HashMap<>(props);
expr = propsCopy.remove(PropConst.EXPR);
if (expr == null) {
throw new IllegalArgumentException("Value does not specified or null");
}
Matcher matcher = PARENT_EXP.matcher(expr);
if (matcher.matches()) {
valueProvider = new ParentProvider();
Map<String, String> params = new HashMap<>(2);
params.put(PropConst.DEPTH, "" + countOccurrence(expr, '.'));
params.put(PropConst.FIELD, matcher.group(2));
valueProvider.init(params);
} else {
matcher = COUNTER_INC.matcher(expr);
if (matcher.matches()) {
Map<String, String> params = new HashMap<>(1);
params.put(PropConst.VAR, matcher.group(1));
valueProvider = new CounterProvider();
valueProvider.init(params);
} else {
valueProvider = new ExpressionProvider();
valueProvider.init(props);
}
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/Sink.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
| import java.util.Map;
import com.presidentio.testdatagenerator.model.Template; | /**
* 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.presidentio.testdatagenerator.output;
public interface Sink {
void init(Map<String, String> props);
| // Path: src/main/java/com/presidentio/testdatagenerator/model/Template.java
// public class Template {
//
// private String id;
//
// private String extend;
//
// @JsonIgnore
// private Template extendTemplate;
//
// private Integer count;
//
// private String name;
//
// private List<Field> fields;
//
// private List<String> childs = new ArrayList<>();
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getExtend() {
// return extend;
// }
//
// public void setExtend(String extend) {
// this.extend = extend;
// }
//
// public Template getExtendTemplate() {
// return extendTemplate;
// }
//
// public void setExtendTemplate(Template extendTemplate) {
// this.extendTemplate = extendTemplate;
// }
//
// public Integer getCount() {
// if (count == null && extendTemplate != null) {
// return extendTemplate.getCount();
// }
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public String getName() {
// if (name == null && extendTemplate != null) {
// return extendTemplate.getName();
// }
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Field> getFields() {
// List<Field> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getFields() != null) {
// result.addAll(extendTemplate.getFields());
// }
// if (fields != null) {
// result.addAll(fields);
// }
// return result;
// }
//
// public void setFields(List<Field> fields) {
// this.fields = fields;
// }
//
// public List<String> getChilds() {
// List<String> result = new ArrayList<>();
// if (extendTemplate != null && extendTemplate.getChilds() != null) {
// result.addAll(extendTemplate.getChilds());
// }
// if (childs != null) {
// result.addAll(childs);
// }
// return result;
// }
//
// public void setChilds(List<String> childs) {
// this.childs = childs;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Template template = (Template) o;
//
// if (name != null ? !name.equals(template.name) : template.name != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return name != null ? name.hashCode() : 0;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/Sink.java
import java.util.Map;
import com.presidentio.testdatagenerator.model.Template;
/**
* 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.presidentio.testdatagenerator.output;
public interface Sink {
void init(Map<String, String> props);
| void process(Template template, Map<String, Object> map); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/EsFileTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Assert;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public class EsFileTest extends AbstractEsTest {
private String indexName = "test_data_generator";
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-es-file-schema.json");
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/EsFileTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Assert;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public class EsFileTest extends AbstractEsTest {
private String indexName = "test_data_generator";
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-es-file-schema.json");
}
@Override | protected void testResult(Output output) { |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/EsFileTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Assert;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public class EsFileTest extends AbstractEsTest {
private String indexName = "test_data_generator";
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-es-file-schema.json");
}
@Override
protected void testResult(Output output) {
try { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/EsFileTest.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.model.Output;
import org.elasticsearch.action.count.CountResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Assert;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public class EsFileTest extends AbstractEsTest {
private String indexName = "test_data_generator";
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-es-file-schema.json");
}
@Override
protected void testResult(Output output) {
try { | executeFile(output.getProps().get(PropConst.FILE)); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/ExpressionBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// public class ExpressionProvider implements ValueProvider {
//
// private String expr;
// private Serializable compiledExpression;
//
// @Override
// public void init(Map<String, String> props) {
// Map<String, String> propsCopy = new HashMap<>(props);
// expr = propsCopy.remove(PropConst.EXPR);
// if (expr == null) {
// throw new IllegalArgumentException("Value does not specified or null");
// }
// if (!propsCopy.isEmpty()) {
// throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy);
// }
// compiledExpression = MVEL.compileExpression(expr);
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Class type;
// switch (field.getType()) {
// case TypeConst.STRING:
// type = String.class;
// break;
// case TypeConst.LONG:
// type = Long.class;
// break;
// case TypeConst.INT:
// type = Integer.class;
// break;
// case TypeConst.BOOLEAN:
// type = Boolean.class;
// break;
// default:
// throw new IllegalArgumentException("Field type not known: " + field.getType());
// }
// synchronized (context.getVariables()) {
// return MVEL.executeExpression(compiledExpression, context, context.getVariables(), type);
// }
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ExpressionProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ExpressionBenchmark {
| // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ExpressionProvider.java
// public class ExpressionProvider implements ValueProvider {
//
// private String expr;
// private Serializable compiledExpression;
//
// @Override
// public void init(Map<String, String> props) {
// Map<String, String> propsCopy = new HashMap<>(props);
// expr = propsCopy.remove(PropConst.EXPR);
// if (expr == null) {
// throw new IllegalArgumentException("Value does not specified or null");
// }
// if (!propsCopy.isEmpty()) {
// throw new IllegalArgumentException("Redundant props for " + getClass().getName() + ": " + propsCopy);
// }
// compiledExpression = MVEL.compileExpression(expr);
// }
//
// @Override
// public Object nextValue(Context context, Field field) {
// Class type;
// switch (field.getType()) {
// case TypeConst.STRING:
// type = String.class;
// break;
// case TypeConst.LONG:
// type = Long.class;
// break;
// case TypeConst.INT:
// type = Integer.class;
// break;
// case TypeConst.BOOLEAN:
// type = Boolean.class;
// break;
// default:
// throw new IllegalArgumentException("Field type not known: " + field.getType());
// }
// synchronized (context.getVariables()) {
// return MVEL.executeExpression(compiledExpression, context, context.getVariables(), type);
// }
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/provider/ValueProvider.java
// public interface ValueProvider {
//
// void init(Map<String, String> props);
//
// Object nextValue(Context context, Field field);
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/ExpressionBenchmark.java
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import com.presidentio.testdatagenerator.provider.ExpressionProvider;
import com.presidentio.testdatagenerator.provider.ValueProvider;
import org.openjdk.jmh.annotations.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/19/2015.
*/
@Fork(1)
@Warmup(iterations = 3)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Measurement(iterations = 10)
@State(Scope.Benchmark)
public class ExpressionBenchmark {
| private Context context; |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/SqlDirectTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List; | /**
* 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.presidentio.testdatagenerator;
public class SqlDirectTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-direct-schema.json");
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/SqlDirectTest.java
import com.presidentio.testdatagenerator.model.Output;
import org.junit.Assert;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
/**
* 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.presidentio.testdatagenerator;
public class SqlDirectTest extends AbstractSqlTest {
@Override
protected List<String> getSchemaResource() {
return Arrays.asList("test-sql-direct-schema.json");
}
@Override | protected void testResult(Output output) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/stream/stop/LimitedTickStopManager.java | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
| import com.presidentio.testdatagenerator.context.Context; | package com.presidentio.testdatagenerator.stream.stop;
/**
* Created by presidentio on 24.04.15.
*/
public class LimitedTickStopManager implements StopManager {
private long limit = Long.MAX_VALUE;
private long tickCount;
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/stream/stop/LimitedTickStopManager.java
import com.presidentio.testdatagenerator.context.Context;
package com.presidentio.testdatagenerator.stream.stop;
/**
* Created by presidentio on 24.04.15.
*/
public class LimitedTickStopManager implements StopManager {
private long limit = Long.MAX_VALUE;
private long tickCount;
@Override | public boolean isStop(Context context) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/stream/stop/InfiniteStopManager.java | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
| import com.presidentio.testdatagenerator.context.Context; | package com.presidentio.testdatagenerator.stream.stop;
/**
* Created by presidentio on 24.04.15.
*/
public class InfiniteStopManager implements StopManager {
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/stream/stop/InfiniteStopManager.java
import com.presidentio.testdatagenerator.context.Context;
package com.presidentio.testdatagenerator.stream.stop;
/**
* Created by presidentio on 24.04.15.
*/
public class InfiniteStopManager implements StopManager {
@Override | public boolean isStop(Context context) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/SqlDirectSink.java | // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java
// public interface Formatter {
//
// void init(Map<String, String> props);
//
// String format(Map<String, Object> map, Template template);
//
// String format(List<Map<String, Object>> maps, Template template);
//
// boolean supportMultiInsert();
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SqlFormatter.java
// public class SqlFormatter implements Formatter {
//
// public static final String INSERT_TEMPlATE = "INSERT INTO %s %s VALUES %s;\n";
// public static final String MULTI_INSERT_TEMPlATE_START = "INSERT INTO %s %s VALUES \n";
// public static final String MULTI_INSERT_TEMPlATE_END = ";";
// public static final String COMMA = ", ";
//
// private static final List<String> JDBC_DRIVERS_WITH_MULTI_INSERT = Arrays.asList("org.postgresql.Driver",
// "com.mysql.jdbc.Driver");
//
// private boolean supportMultiInsert;
//
// @Override
// public void init(Map<String, String> props) {
// String jdbcDriver = props.get(PropConst.JDBC_DRIVER);
// if (jdbcDriver != null) {
// supportMultiInsert = JDBC_DRIVERS_WITH_MULTI_INSERT.contains(jdbcDriver);
// }
// }
//
// @Override
// public String format(Map<String, Object> map, Template template) {
// String columns = getColumns(template);
// String values = getValues(map, template);
// return String.format(INSERT_TEMPlATE, template.getName(), columns, values);
// }
//
// private String getColumns(Template template) {
// StringBuilder columns = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// columns.append(COMMA);
// }
// first = false;
// columns.append(field.getName());
// }
// columns.append(")");
// return columns.toString();
// }
//
// private String getValues(Map<String, Object> map, Template template) {
// StringBuilder values = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// values.append(COMMA);
// }
// first = false;
// values.append(formatValue(field.getType(), map.get(field.getName())));
// }
// values.append(")");
// return values.toString();
// }
//
// @Override
// public String format(List<Map<String, Object>> maps, Template template) {
// if (supportMultiInsert) {
// return formatMultiInsert(maps, template);
// } else {
// StringBuilder stringBuilder = new StringBuilder();
// for (Map<String, Object> map : maps) {
// stringBuilder.append(format(map, template));
// }
// return stringBuilder.toString();
// }
// }
//
// private String formatMultiInsert(List<Map<String, Object>> maps, Template template) {
// String columns = getColumns(template);
// String start = String.format(MULTI_INSERT_TEMPlATE_START, template.getName(), columns);
// StringBuilder stringBuilder = new StringBuilder(start);
// boolean first = true;
// for (Map<String, Object> map : maps) {
// if (!first) {
// stringBuilder.append(COMMA);
// }
// first = false;
// stringBuilder.append(getValues(map, template));
// }
// stringBuilder.append(MULTI_INSERT_TEMPlATE_END);
// return stringBuilder.toString();
// }
//
// protected String formatValue(String type, Object value) {
// switch (type) {
// case TypeConst.STRING:
// return "'" + value + "'";
// case TypeConst.LONG:
// return value.toString();
// case TypeConst.INT:
// return value.toString();
// case TypeConst.BOOLEAN:
// return value.toString();
// default:
// throw new IllegalArgumentException("Field type not known: " + type);
// }
// }
//
// @Override
// public boolean supportMultiInsert() {
// return supportMultiInsert;
// }
// }
| import com.presidentio.testdatagenerator.output.formatter.SqlFormatter;
import java.util.Map;
import com.presidentio.testdatagenerator.output.formatter.Formatter; | /**
* 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.presidentio.testdatagenerator.output;
public class SqlDirectSink extends AbstractJdbcSink {
@Override
public void init(Map<String, String> props) {
super.init(props); | // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java
// public interface Formatter {
//
// void init(Map<String, String> props);
//
// String format(Map<String, Object> map, Template template);
//
// String format(List<Map<String, Object>> maps, Template template);
//
// boolean supportMultiInsert();
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SqlFormatter.java
// public class SqlFormatter implements Formatter {
//
// public static final String INSERT_TEMPlATE = "INSERT INTO %s %s VALUES %s;\n";
// public static final String MULTI_INSERT_TEMPlATE_START = "INSERT INTO %s %s VALUES \n";
// public static final String MULTI_INSERT_TEMPlATE_END = ";";
// public static final String COMMA = ", ";
//
// private static final List<String> JDBC_DRIVERS_WITH_MULTI_INSERT = Arrays.asList("org.postgresql.Driver",
// "com.mysql.jdbc.Driver");
//
// private boolean supportMultiInsert;
//
// @Override
// public void init(Map<String, String> props) {
// String jdbcDriver = props.get(PropConst.JDBC_DRIVER);
// if (jdbcDriver != null) {
// supportMultiInsert = JDBC_DRIVERS_WITH_MULTI_INSERT.contains(jdbcDriver);
// }
// }
//
// @Override
// public String format(Map<String, Object> map, Template template) {
// String columns = getColumns(template);
// String values = getValues(map, template);
// return String.format(INSERT_TEMPlATE, template.getName(), columns, values);
// }
//
// private String getColumns(Template template) {
// StringBuilder columns = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// columns.append(COMMA);
// }
// first = false;
// columns.append(field.getName());
// }
// columns.append(")");
// return columns.toString();
// }
//
// private String getValues(Map<String, Object> map, Template template) {
// StringBuilder values = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// values.append(COMMA);
// }
// first = false;
// values.append(formatValue(field.getType(), map.get(field.getName())));
// }
// values.append(")");
// return values.toString();
// }
//
// @Override
// public String format(List<Map<String, Object>> maps, Template template) {
// if (supportMultiInsert) {
// return formatMultiInsert(maps, template);
// } else {
// StringBuilder stringBuilder = new StringBuilder();
// for (Map<String, Object> map : maps) {
// stringBuilder.append(format(map, template));
// }
// return stringBuilder.toString();
// }
// }
//
// private String formatMultiInsert(List<Map<String, Object>> maps, Template template) {
// String columns = getColumns(template);
// String start = String.format(MULTI_INSERT_TEMPlATE_START, template.getName(), columns);
// StringBuilder stringBuilder = new StringBuilder(start);
// boolean first = true;
// for (Map<String, Object> map : maps) {
// if (!first) {
// stringBuilder.append(COMMA);
// }
// first = false;
// stringBuilder.append(getValues(map, template));
// }
// stringBuilder.append(MULTI_INSERT_TEMPlATE_END);
// return stringBuilder.toString();
// }
//
// protected String formatValue(String type, Object value) {
// switch (type) {
// case TypeConst.STRING:
// return "'" + value + "'";
// case TypeConst.LONG:
// return value.toString();
// case TypeConst.INT:
// return value.toString();
// case TypeConst.BOOLEAN:
// return value.toString();
// default:
// throw new IllegalArgumentException("Field type not known: " + type);
// }
// }
//
// @Override
// public boolean supportMultiInsert() {
// return supportMultiInsert;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/SqlDirectSink.java
import com.presidentio.testdatagenerator.output.formatter.SqlFormatter;
import java.util.Map;
import com.presidentio.testdatagenerator.output.formatter.Formatter;
/**
* 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.presidentio.testdatagenerator.output;
public class SqlDirectSink extends AbstractJdbcSink {
@Override
public void init(Map<String, String> props) {
super.init(props); | Formatter formatter = new SqlFormatter(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/SqlDirectSink.java | // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java
// public interface Formatter {
//
// void init(Map<String, String> props);
//
// String format(Map<String, Object> map, Template template);
//
// String format(List<Map<String, Object>> maps, Template template);
//
// boolean supportMultiInsert();
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SqlFormatter.java
// public class SqlFormatter implements Formatter {
//
// public static final String INSERT_TEMPlATE = "INSERT INTO %s %s VALUES %s;\n";
// public static final String MULTI_INSERT_TEMPlATE_START = "INSERT INTO %s %s VALUES \n";
// public static final String MULTI_INSERT_TEMPlATE_END = ";";
// public static final String COMMA = ", ";
//
// private static final List<String> JDBC_DRIVERS_WITH_MULTI_INSERT = Arrays.asList("org.postgresql.Driver",
// "com.mysql.jdbc.Driver");
//
// private boolean supportMultiInsert;
//
// @Override
// public void init(Map<String, String> props) {
// String jdbcDriver = props.get(PropConst.JDBC_DRIVER);
// if (jdbcDriver != null) {
// supportMultiInsert = JDBC_DRIVERS_WITH_MULTI_INSERT.contains(jdbcDriver);
// }
// }
//
// @Override
// public String format(Map<String, Object> map, Template template) {
// String columns = getColumns(template);
// String values = getValues(map, template);
// return String.format(INSERT_TEMPlATE, template.getName(), columns, values);
// }
//
// private String getColumns(Template template) {
// StringBuilder columns = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// columns.append(COMMA);
// }
// first = false;
// columns.append(field.getName());
// }
// columns.append(")");
// return columns.toString();
// }
//
// private String getValues(Map<String, Object> map, Template template) {
// StringBuilder values = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// values.append(COMMA);
// }
// first = false;
// values.append(formatValue(field.getType(), map.get(field.getName())));
// }
// values.append(")");
// return values.toString();
// }
//
// @Override
// public String format(List<Map<String, Object>> maps, Template template) {
// if (supportMultiInsert) {
// return formatMultiInsert(maps, template);
// } else {
// StringBuilder stringBuilder = new StringBuilder();
// for (Map<String, Object> map : maps) {
// stringBuilder.append(format(map, template));
// }
// return stringBuilder.toString();
// }
// }
//
// private String formatMultiInsert(List<Map<String, Object>> maps, Template template) {
// String columns = getColumns(template);
// String start = String.format(MULTI_INSERT_TEMPlATE_START, template.getName(), columns);
// StringBuilder stringBuilder = new StringBuilder(start);
// boolean first = true;
// for (Map<String, Object> map : maps) {
// if (!first) {
// stringBuilder.append(COMMA);
// }
// first = false;
// stringBuilder.append(getValues(map, template));
// }
// stringBuilder.append(MULTI_INSERT_TEMPlATE_END);
// return stringBuilder.toString();
// }
//
// protected String formatValue(String type, Object value) {
// switch (type) {
// case TypeConst.STRING:
// return "'" + value + "'";
// case TypeConst.LONG:
// return value.toString();
// case TypeConst.INT:
// return value.toString();
// case TypeConst.BOOLEAN:
// return value.toString();
// default:
// throw new IllegalArgumentException("Field type not known: " + type);
// }
// }
//
// @Override
// public boolean supportMultiInsert() {
// return supportMultiInsert;
// }
// }
| import com.presidentio.testdatagenerator.output.formatter.SqlFormatter;
import java.util.Map;
import com.presidentio.testdatagenerator.output.formatter.Formatter; | /**
* 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.presidentio.testdatagenerator.output;
public class SqlDirectSink extends AbstractJdbcSink {
@Override
public void init(Map<String, String> props) {
super.init(props); | // Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/Formatter.java
// public interface Formatter {
//
// void init(Map<String, String> props);
//
// String format(Map<String, Object> map, Template template);
//
// String format(List<Map<String, Object>> maps, Template template);
//
// boolean supportMultiInsert();
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/SqlFormatter.java
// public class SqlFormatter implements Formatter {
//
// public static final String INSERT_TEMPlATE = "INSERT INTO %s %s VALUES %s;\n";
// public static final String MULTI_INSERT_TEMPlATE_START = "INSERT INTO %s %s VALUES \n";
// public static final String MULTI_INSERT_TEMPlATE_END = ";";
// public static final String COMMA = ", ";
//
// private static final List<String> JDBC_DRIVERS_WITH_MULTI_INSERT = Arrays.asList("org.postgresql.Driver",
// "com.mysql.jdbc.Driver");
//
// private boolean supportMultiInsert;
//
// @Override
// public void init(Map<String, String> props) {
// String jdbcDriver = props.get(PropConst.JDBC_DRIVER);
// if (jdbcDriver != null) {
// supportMultiInsert = JDBC_DRIVERS_WITH_MULTI_INSERT.contains(jdbcDriver);
// }
// }
//
// @Override
// public String format(Map<String, Object> map, Template template) {
// String columns = getColumns(template);
// String values = getValues(map, template);
// return String.format(INSERT_TEMPlATE, template.getName(), columns, values);
// }
//
// private String getColumns(Template template) {
// StringBuilder columns = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// columns.append(COMMA);
// }
// first = false;
// columns.append(field.getName());
// }
// columns.append(")");
// return columns.toString();
// }
//
// private String getValues(Map<String, Object> map, Template template) {
// StringBuilder values = new StringBuilder("(");
// boolean first = true;
// for (Field field : template.getFields()) {
// if (!first) {
// values.append(COMMA);
// }
// first = false;
// values.append(formatValue(field.getType(), map.get(field.getName())));
// }
// values.append(")");
// return values.toString();
// }
//
// @Override
// public String format(List<Map<String, Object>> maps, Template template) {
// if (supportMultiInsert) {
// return formatMultiInsert(maps, template);
// } else {
// StringBuilder stringBuilder = new StringBuilder();
// for (Map<String, Object> map : maps) {
// stringBuilder.append(format(map, template));
// }
// return stringBuilder.toString();
// }
// }
//
// private String formatMultiInsert(List<Map<String, Object>> maps, Template template) {
// String columns = getColumns(template);
// String start = String.format(MULTI_INSERT_TEMPlATE_START, template.getName(), columns);
// StringBuilder stringBuilder = new StringBuilder(start);
// boolean first = true;
// for (Map<String, Object> map : maps) {
// if (!first) {
// stringBuilder.append(COMMA);
// }
// first = false;
// stringBuilder.append(getValues(map, template));
// }
// stringBuilder.append(MULTI_INSERT_TEMPlATE_END);
// return stringBuilder.toString();
// }
//
// protected String formatValue(String type, Object value) {
// switch (type) {
// case TypeConst.STRING:
// return "'" + value + "'";
// case TypeConst.LONG:
// return value.toString();
// case TypeConst.INT:
// return value.toString();
// case TypeConst.BOOLEAN:
// return value.toString();
// default:
// throw new IllegalArgumentException("Field type not known: " + type);
// }
// }
//
// @Override
// public boolean supportMultiInsert() {
// return supportMultiInsert;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/SqlDirectSink.java
import com.presidentio.testdatagenerator.output.formatter.SqlFormatter;
import java.util.Map;
import com.presidentio.testdatagenerator.output.formatter.Formatter;
/**
* 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.presidentio.testdatagenerator.output;
public class SqlDirectSink extends AbstractJdbcSink {
@Override
public void init(Map<String, String> props) {
super.init(props); | Formatter formatter = new SqlFormatter(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/AbstractJdbcSink.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
| import com.presidentio.testdatagenerator.cons.PropConst;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map; | /**
* 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.presidentio.testdatagenerator.output;
public abstract class AbstractJdbcSink extends AbstractBufferedSink {
private Connection connection;
@Override
public void init(Map<String, String> props) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/AbstractJdbcSink.java
import com.presidentio.testdatagenerator.cons.PropConst;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
/**
* 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.presidentio.testdatagenerator.output;
public abstract class AbstractJdbcSink extends AbstractBufferedSink {
private Connection connection;
@Override
public void init(Map<String, String> props) { | String connectionUrl = props.get(PropConst.CONNECTION_URL); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map; | package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) { | String format = props.get(PropConst.FORMAT); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map; | package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) {
String format = props.get(PropConst.FORMAT);
if (format == null) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) {
String format = props.get(PropConst.FORMAT);
if (format == null) { | format = FileFormatConst.CSV; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map; | package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) {
String format = props.get(PropConst.FORMAT);
if (format == null) {
format = FileFormatConst.CSV;
}
if (!FileFormatConst.ALL.contains(format)) {
throw new IllegalArgumentException(PropConst.FORMAT + " is incorrect. Must be one of: "
+ FileFormatConst.ALL);
}
Formatter formatter = getFormatter(format);
formatter.init(props);
return formatter;
}
private Formatter getFormatter(String format) {
switch (format) {
case FileFormatConst.CSV: | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/FileFormatConst.java
// public class FileFormatConst {
//
// public static final String CSV = "csv";
// public static final String TSV = "tsv";
// public static final String JSON = "json";
// public static final String SQL = "sql";
// public static final String ES = "es";
//
// public static final List<String> ALL = Arrays.asList(CSV, TSV, JSON, SQL, ES);
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/formatter/DefaultFormatterFactory.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.FileFormatConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import java.util.Map;
package com.presidentio.testdatagenerator.output.formatter;
/**
* Created by presidentio on 24.04.15.
*/
public class DefaultFormatterFactory implements FormatterFactory {
@Override
public Formatter buildFormatter(Map<String, String> props) {
String format = props.get(PropConst.FORMAT);
if (format == null) {
format = FileFormatConst.CSV;
}
if (!FileFormatConst.ALL.contains(format)) {
throw new IllegalArgumentException(PropConst.FORMAT + " is incorrect. Must be one of: "
+ FileFormatConst.ALL);
}
Formatter formatter = getFormatter(format);
formatter.init(props);
return formatter;
}
private Formatter getFormatter(String format) {
switch (format) {
case FileFormatConst.CSV: | return new SvFormatter(DelimiterConst.COMMA); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/output/SinkFactory.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/SinkTypeConst.java
// public class SinkTypeConst {
//
// public static final String CONSOLE = "console";
// public static final String FILE = "file";
// public static final String SQL_DIRECT = "sql-direct";
// public static final String ES_DIRECT = "es-direct";
// public static final String KAFKA = "kafka";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
| import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.cons.SinkTypeConst; | /**
* 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.presidentio.testdatagenerator.output;
public class SinkFactory {
public Sink getSink(Output output) {
Sink sink;
switch (output.getType()) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/SinkTypeConst.java
// public class SinkTypeConst {
//
// public static final String CONSOLE = "console";
// public static final String FILE = "file";
// public static final String SQL_DIRECT = "sql-direct";
// public static final String ES_DIRECT = "es-direct";
// public static final String KAFKA = "kafka";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Output.java
// public class Output {
//
// private String type;
//
// @JsonDeserialize(contentUsing = StringDeserializer.class)
// private Map<String, String> props;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Map<String, String> getProps() {
// return props;
// }
//
// public void setProps(Map<String, String> props) {
// this.props = props;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/output/SinkFactory.java
import com.presidentio.testdatagenerator.model.Output;
import com.presidentio.testdatagenerator.cons.SinkTypeConst;
/**
* 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.presidentio.testdatagenerator.output;
public class SinkFactory {
public Sink getSink(Output output) {
Sink sink;
switch (output.getType()) { | case SinkTypeConst.CONSOLE: |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections; | /**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/TypeConst.java
// public class TypeConst {
//
// public static final String STRING = "string";
// public static final String LONG = "long";
// public static final String INT = "int";
// public static final String BOOLEAN = "boolean";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/test/java/com/presidentio/testdatagenerator/provider/CountryValueProviderTest.java
import com.presidentio.testdatagenerator.cons.TypeConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
/**
* 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.presidentio.testdatagenerator.provider;
/**
* Created by Vitaliy on 24.01.2015.
*/
public class CountryValueProviderTest {
@Test
public void testNextValue() throws Exception {
ValueProvider valueProvider = new CountryProvider();
valueProvider.init(Collections.<String, String>emptyMap()); | Assert.assertNotNull(valueProvider.nextValue(new Context(null, null, null), new Field(null, TypeConst.STRING, null))); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() { | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java
import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() { | SchemaBuilder schemaBuilder = new SchemaBuilder(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : Arrays.asList("test-es-file-schema.json")) {
schemaBuilder.fromResource(resource);
} | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java
import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : Arrays.asList("test-es-file-schema.json")) {
schemaBuilder.fromResource(resource);
} | Schema schema = schemaBuilder.build(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
| import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays; | package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : Arrays.asList("test-es-file-schema.json")) {
schemaBuilder.fromResource(resource);
}
Schema schema = schemaBuilder.build(); | // Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
// public class OneTimeGenerator extends AbstractGenerator {
//
// private boolean async = false;
// private Integer threadCount = Runtime.getRuntime().availableProcessors();
//
// @Override
// public void generate(Context context, Schema schema) {
// InitTask initTask = new InitTask(context, schema.getRoot());
// initTask.setSinkFactory(getSinkFactory());
// initTask.setValueProviderFactory(getValueProviderFactory());
// initTask.setAsync(async);
// if (async) {
// ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
// forkJoinPool.invoke(initTask);
// } else {
// initTask.compute();
// }
// }
//
// public boolean isAsync() {
// return async;
// }
//
// public void setAsync(boolean async) {
// this.async = async;
// }
//
// public Integer getThreadCount() {
// return threadCount;
// }
//
// public void setThreadCount(Integer threadCount) {
// this.threadCount = threadCount;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/parser/SchemaBuilder.java
// public class SchemaBuilder {
//
// private List<Schema> schemas = new ArrayList<>();
//
// public SchemaBuilder fromResource(String resource) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(
// SchemaBuilder.class.getClassLoader().getResourceAsStream(resource));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public SchemaBuilder fromFile(String file) {
// SchemaSerializer schemaSerializer = new JsonSchemaSerializer();
// try {
// Schema schema = schemaSerializer.deserialize(new FileInputStream(file));
// schemas.add(schema);
// return this;
// } catch (IOException e) {
// throw new IllegalStateException(e);
// }
// }
//
// public Schema build() {
// Schema schema = null;
// for (Schema schema1 : schemas) {
// if (schema == null) {
// schema = schema1;
// } else {
// schema = merge(schema, schema1);
// }
// }
// if (schema != null) {
// for (Template template : schema.getTemplates()) {
// if (template.getExtend() != null) {
// for (Template parentTemplate : schema.getTemplates()) {
// if (parentTemplate.getId().equals(template.getExtend())) {
// template.setExtendTemplate(parentTemplate);
// break;
// }
// }
// }
// }
// }
// return schema;
// }
//
// private Schema merge(Schema schema1, Schema schema2) {
// schema1.getTemplates().addAll(schema2.getTemplates());
// schema1.getRoot().addAll(schema2.getRoot());
// schema1.getVariables().addAll(schema2.getVariables());
// if (schema1.getOutput() != null && schema2.getOutput() != null) {
// throw new IllegalArgumentException("Can't merge two outputs");
// }
// if (schema1.getOutput() == null) {
// schema1.setOutput(schema2.getOutput());
// }
// return schema1;
// }
//
// }
// Path: src/main/java/com/presidentio/testdatagenerator/benchmark/EsFileBenchmark.java
import com.presidentio.testdatagenerator.OneTimeGenerator;
import com.presidentio.testdatagenerator.model.Schema;
import com.presidentio.testdatagenerator.parser.SchemaBuilder;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
package com.presidentio.testdatagenerator.benchmark;
/**
* Created by Vitalii_Gergel on 3/17/2015.
*/
public class EsFileBenchmark {
@Fork(1)
@Warmup(iterations = 3)
@Benchmark
public void measureEsDirect() {
SchemaBuilder schemaBuilder = new SchemaBuilder();
for (String resource : Arrays.asList("test-es-file-schema.json")) {
schemaBuilder.fromResource(resource);
}
Schema schema = schemaBuilder.build(); | OneTimeGenerator generator = new OneTimeGenerator(); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | package com.presidentio.testdatagenerator.provider;
/**
* Created by Vitalii_Gergel on 2/11/2015.
*/
public class PeopleNameProvider implements ValueProvider {
private static String[] MALE_FIRST_NAMES;
private static String[] FEMALE_FIRST_NAMES;
private static String[] LAST_NAMES;
private Random random = new Random();
private boolean firstName = true;
private boolean lastName = true;
private boolean male = true;
private boolean female = true;
private String[] getMaleNames() {
if (MALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("male-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream); | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
package com.presidentio.testdatagenerator.provider;
/**
* Created by Vitalii_Gergel on 2/11/2015.
*/
public class PeopleNameProvider implements ValueProvider {
private static String[] MALE_FIRST_NAMES;
private static String[] FEMALE_FIRST_NAMES;
private static String[] LAST_NAMES;
private Random random = new Random();
private boolean firstName = true;
private boolean lastName = true;
private boolean male = true;
private boolean female = true;
private String[] getMaleNames() {
if (MALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("male-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream); | MALE_FIRST_NAMES = namesStr.split(DelimiterConst.COMMA); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | }
private String[] getFemaleNames() {
if (FEMALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("female-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
FEMALE_FIRST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return FEMALE_FIRST_NAMES;
}
private String[] getLastNames() {
if (LAST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("last-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
LAST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
}
private String[] getFemaleNames() {
if (FEMALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("female-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
FEMALE_FIRST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return FEMALE_FIRST_NAMES;
}
private String[] getLastNames() {
if (LAST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("last-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
LAST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) { | String gender = props.get(PropConst.GENDER); |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | private String[] getFemaleNames() {
if (FEMALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("female-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
FEMALE_FIRST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return FEMALE_FIRST_NAMES;
}
private String[] getLastNames() {
if (LAST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("last-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
LAST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) {
String gender = props.get(PropConst.GENDER);
if (gender == null) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
private String[] getFemaleNames() {
if (FEMALE_FIRST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("female-first-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
FEMALE_FIRST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return FEMALE_FIRST_NAMES;
}
private String[] getLastNames() {
if (LAST_NAMES == null) {
try (InputStream nameStream = DefaultValueProviderFactory.class.getClassLoader()
.getResourceAsStream("last-name.dat")) {
String namesStr = IOUtils.toString(nameStream);
LAST_NAMES = namesStr.split(DelimiterConst.COMMA);
} catch (IOException e) {
throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) {
String gender = props.get(PropConst.GENDER);
if (gender == null) { | gender = GenderConst.ALL; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) {
String gender = props.get(PropConst.GENDER);
if (gender == null) {
gender = GenderConst.ALL;
}
switch (gender) {
case GenderConst.ALL:
male = true;
female = true;
break;
case GenderConst.MALE:
male = true;
female = false;
break;
case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) { | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
throw new RuntimeException("Failed to load names", e);
}
}
return LAST_NAMES;
}
@Override
public void init(Map<String, String> props) {
String gender = props.get(PropConst.GENDER);
if (gender == null) {
gender = GenderConst.ALL;
}
switch (gender) {
case GenderConst.ALL:
male = true;
female = true;
break;
case GenderConst.MALE:
male = true;
female = false;
break;
case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) { | type = NameTypeConst.ALL; |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) {
type = NameTypeConst.ALL;
}
switch (type) {
case NameTypeConst.ALL:
firstName = true;
lastName = true;
break;
case NameTypeConst.FIRST:
firstName = true;
lastName = false;
break;
case NameTypeConst.LAST:
firstName = false;
lastName = true;
break;
default:
throw new IllegalArgumentException("Unknown name type: " + gender);
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) {
type = NameTypeConst.ALL;
}
switch (type) {
case NameTypeConst.ALL:
firstName = true;
lastName = true;
break;
case NameTypeConst.FIRST:
firstName = true;
lastName = false;
break;
case NameTypeConst.LAST:
firstName = false;
lastName = true;
break;
default:
throw new IllegalArgumentException("Unknown name type: " + gender);
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
| import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random; | case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) {
type = NameTypeConst.ALL;
}
switch (type) {
case NameTypeConst.ALL:
firstName = true;
lastName = true;
break;
case NameTypeConst.FIRST:
firstName = true;
lastName = false;
break;
case NameTypeConst.LAST:
firstName = false;
lastName = true;
break;
default:
throw new IllegalArgumentException("Unknown name type: " + gender);
}
}
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/cons/DelimiterConst.java
// public class DelimiterConst {
//
// public static final String COMMA = ",";
// public static final String TAB = "\t";
// public static final String NEW_LINE = "\n";
// public static final String SPACE = " ";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/GenderConst.java
// public class GenderConst {
//
// public static final String MALE = "male";
// public static final String FEMALE = "female";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/NameTypeConst.java
// public class NameTypeConst {
//
// public static final String FIRST = "first";
// public static final String LAST = "last";
// public static final String ALL = "all";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/cons/PropConst.java
// public class PropConst {
//
// public static final String TYPE = "type";
// public static final String VALUE = "value";
// public static final String SIZE = "size";
// public static final String DOMAIN = "domain";
// public static final String EXPR = "expr";
// public static final String FILE = "file";
// public static final String DELIMITER = "delimiter";
// public static final String ITEMS = "items";
// public static final String INDEX = "index";
// public static final String HOST = "host";
// public static final String PORT = "port";
// public static final String CLUSTER_NAME = "clusterName";
// public static final String CONNECTION_URL = "connectionUrl";
// public static final String JDBC_DRIVER = "jdbcDriver";
// public static final String DEPTH = "depth";
// public static final String FIELD = "field";
// public static final String VAR = "var";
// public static final String OP = "op";
// public static final String FORMAT = "format";
// public static final String HEADER = "header";
// public static final String SUFFIX = "suffix";
// public static final String PREFIX = "prefix";
// public static final String PATH_PROVIDER = "pathProvider";
// public static final String BROKER_LIST = "brokerList";
// public static final String GENDER = "gender";
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Field.java
// public class Field {
//
// private String name;
//
// private String type;
//
// private Provider provider;
//
// public Field() {
// }
//
// public Field(String name, String type, Provider provider) {
// this.name = name;
// this.type = type;
// this.provider = provider;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public Provider getProvider() {
// return provider;
// }
//
// public void setProvider(Provider provider) {
// this.provider = provider;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/provider/PeopleNameProvider.java
import com.presidentio.testdatagenerator.cons.DelimiterConst;
import com.presidentio.testdatagenerator.cons.GenderConst;
import com.presidentio.testdatagenerator.cons.NameTypeConst;
import com.presidentio.testdatagenerator.cons.PropConst;
import com.presidentio.testdatagenerator.context.Context;
import com.presidentio.testdatagenerator.model.Field;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Random;
case GenderConst.FEMALE:
male = false;
female = true;
break;
default:
throw new IllegalArgumentException("Unknown gender: " + gender);
}
String type = props.get(PropConst.TYPE);
if (type == null) {
type = NameTypeConst.ALL;
}
switch (type) {
case NameTypeConst.ALL:
firstName = true;
lastName = true;
break;
case NameTypeConst.FIRST:
firstName = true;
lastName = false;
break;
case NameTypeConst.LAST:
firstName = false;
lastName = true;
break;
default:
throw new IllegalArgumentException("Unknown name type: " + gender);
}
}
@Override | public Object nextValue(Context context, Field field) { |
presidentio/test-data-generator | src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
| import com.presidentio.testdatagenerator.model.Schema;
import java.util.concurrent.ForkJoinPool;
import com.presidentio.testdatagenerator.context.Context; | /**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator;
public class OneTimeGenerator extends AbstractGenerator {
private boolean async = false;
private Integer threadCount = Runtime.getRuntime().availableProcessors();
@Override | // Path: src/main/java/com/presidentio/testdatagenerator/context/Context.java
// public class Context {
//
// private Parent parent;
//
// private Map<String, Template> templates;
//
// private Map<String, Object> variables;
//
// private Sink sink;
//
// public Context(Map<String, Template> templates, Map<String, Object> variables, Sink sink) {
// this.templates = templates;
// this.variables = variables;
// this.sink = sink;
// }
//
// public Context(Context parentContext, Map<String, Object> entity) {
// parent = new Parent(entity, parentContext.getParent());
// templates = parentContext.getTemplates();
// variables = parentContext.getVariables();
// sink = parentContext.getSink();
// }
//
// public Parent getParent() {
// return parent;
// }
//
// public Map<String, Object> getVariables() {
// return variables;
// }
//
// public Sink getSink() {
// return sink;
// }
//
// public Map<String, Template> getTemplates() {
// return templates;
// }
//
// }
//
// Path: src/main/java/com/presidentio/testdatagenerator/model/Schema.java
// public class Schema {
//
// private List<Template> templates = new ArrayList<>();
//
// private List<String> root = new ArrayList<>();
//
// private List<Variable> variables = new ArrayList<>();
//
// private Output output;
//
// public List<Template> getTemplates() {
// return templates;
// }
//
// public void setTemplates(List<Template> templates) {
// this.templates = templates;
// }
//
// public List<String> getRoot() {
// return root;
// }
//
// public void setRoot(List<String> root) {
// this.root = root;
// }
//
// public List<Variable> getVariables() {
// return variables;
// }
//
// public void setVariables(List<Variable> variables) {
// this.variables = variables;
// }
//
// public Output getOutput() {
// return output;
// }
//
// public void setOutput(Output output) {
// this.output = output;
// }
// }
// Path: src/main/java/com/presidentio/testdatagenerator/OneTimeGenerator.java
import com.presidentio.testdatagenerator.model.Schema;
import java.util.concurrent.ForkJoinPool;
import com.presidentio.testdatagenerator.context.Context;
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.presidentio.testdatagenerator;
public class OneTimeGenerator extends AbstractGenerator {
private boolean async = false;
private Integer threadCount = Runtime.getRuntime().availableProcessors();
@Override | public void generate(Context context, Schema schema) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.