id
stringlengths
7
14
test_class
dict
test_case
dict
focal_class
dict
focal_method
dict
repository
dict
204463745_40
{ "fields": [ { "declarator": "messages = new ArrayList<>()", "modifier": "private final", "original_string": "private final List<TxEvent> messages = new ArrayList<>();", "type": "List<TxEvent>", "var_name": "messages" }, { "declarator": "sender = new MessageSender() {\n @Override\n public void onConnected() {\n\n }\n\n @Override\n public void onDisconnected() {\n\n }\n\n @Override\n public void close() {\n\n }\n\n @Override\n public String target() {\n return \"UNKNOWN\";\n }\n\n @Override\n public AlphaResponse send(TxEvent event) {\n messages.add(event);\n return new AlphaResponse(false);\n }\n\n @Override\n public Set<String> send(Set<String> localTxIdSet) {\n return null;\n }\n\n @Override\n public String reportMessageToServer(KafkaMessage message) {\n return \"\";\n }\n\n @Override\n public String reportAccidentToServer(AccidentHandling accidentHandling) {\n return null;\n }\n\n @Override\n public GrpcConfigAck readConfigFromServer(int type, String category) {\n return null;\n }\n }", "modifier": "private final", "original_string": "private final MessageSender sender = new MessageSender() {\n @Override\n public void onConnected() {\n\n }\n\n @Override\n public void onDisconnected() {\n\n }\n\n @Override\n public void close() {\n\n }\n\n @Override\n public String target() {\n return \"UNKNOWN\";\n }\n\n @Override\n public AlphaResponse send(TxEvent event) {\n messages.add(event);\n return new AlphaResponse(false);\n }\n\n @Override\n public Set<String> send(Set<String> localTxIdSet) {\n return null;\n }\n\n @Override\n public String reportMessageToServer(KafkaMessage message) {\n return \"\";\n }\n\n @Override\n public String reportAccidentToServer(AccidentHandling accidentHandling) {\n return null;\n }\n\n @Override\n public GrpcConfigAck readConfigFromServer(int type, String category) {\n return null;\n }\n };", "type": "MessageSender", "var_name": "sender" }, { "declarator": "globalTxId = UUID.randomUUID().toString()", "modifier": "private final", "original_string": "private final String globalTxId = UUID.randomUUID().toString();", "type": "String", "var_name": "globalTxId" }, { "declarator": "generator = mock(IdGenerator.class)", "modifier": "@SuppressWarnings(\"unchecked\")\n private final", "original_string": "@SuppressWarnings(\"unchecked\")\n private final IdGenerator<String> generator = mock(IdGenerator.class);", "type": "IdGenerator<String>", "var_name": "generator" }, { "declarator": "context = new OmegaContext(generator)", "modifier": "private final", "original_string": "private final OmegaContext context = new OmegaContext(generator);", "type": "OmegaContext", "var_name": "context" }, { "declarator": "exception = new OmegaException(\"exception\", new RuntimeException(\"runtime exception\"))", "modifier": "private final", "original_string": "private final OmegaException exception = new OmegaException(\"exception\", new RuntimeException(\"runtime exception\"));", "type": "OmegaException", "var_name": "exception" }, { "declarator": "sagaStartAnnotationProcessor = new SagaStartAnnotationProcessor(context,\n sender)", "modifier": "private final", "original_string": "private final SagaStartAnnotationProcessor sagaStartAnnotationProcessor = new SagaStartAnnotationProcessor(context,\n sender);", "type": "SagaStartAnnotationProcessor", "var_name": "sagaStartAnnotationProcessor" } ], "file": "omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java", "identifier": "SagaStartAnnotationProcessorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void sendsSagaStartedEvent() {\n sagaStartAnnotationProcessor.preIntercept(null, null, 0, null, 0);\n\n TxEvent event = messages.get(0);\n\n assertThat(event.globalTxId(), is(globalTxId));\n assertThat(event.localTxId(), is(globalTxId));\n assertThat(event.parentTxId(), is(nullValue()));\n assertThat(event.compensationMethod().isEmpty(), is(true));\n assertThat(event.type(), is(EventType.SagaStartedEvent));\n assertThat(event.payloads().length, is(0));\n }", "class_method_signature": "SagaStartAnnotationProcessorTest.sendsSagaStartedEvent()", "constructor": false, "full_signature": "@Test public void sendsSagaStartedEvent()", "identifier": "sendsSagaStartedEvent", "invocations": [ "preIntercept", "get", "assertThat", "globalTxId", "is", "assertThat", "localTxId", "is", "assertThat", "parentTxId", "is", "nullValue", "assertThat", "isEmpty", "compensationMethod", "is", "assertThat", "type", "is", "assertThat", "payloads", "is" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void sendsSagaStartedEvent()", "testcase": true }
{ "fields": [ { "declarator": "omegaContext", "modifier": "private final", "original_string": "private final OmegaContext omegaContext;", "type": "OmegaContext", "var_name": "omegaContext" }, { "declarator": "sender", "modifier": "private final", "original_string": "private final MessageSender sender;", "type": "MessageSender", "var_name": "sender" } ], "file": "omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java", "identifier": "SagaStartAnnotationProcessor", "interfaces": "implements EventAwareInterceptor", "methods": [ { "class_method_signature": "SagaStartAnnotationProcessor.SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender)", "constructor": true, "full_signature": " SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender)", "identifier": "SagaStartAnnotationProcessor", "modifiers": "", "parameters": "(OmegaContext omegaContext, MessageSender sender)", "return": "", "signature": " SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender sender)", "testcase": false }, { "class_method_signature": "SagaStartAnnotationProcessor.preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "constructor": false, "full_signature": "@Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "identifier": "preIntercept", "modifiers": "@Override public", "parameters": "(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "return": "AlphaResponse", "signature": "AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "testcase": false }, { "class_method_signature": "SagaStartAnnotationProcessor.postIntercept(String parentTxId, String compensationMethod)", "constructor": false, "full_signature": "@Override public void postIntercept(String parentTxId, String compensationMethod)", "identifier": "postIntercept", "modifiers": "@Override public", "parameters": "(String parentTxId, String compensationMethod)", "return": "void", "signature": "void postIntercept(String parentTxId, String compensationMethod)", "testcase": false }, { "class_method_signature": "SagaStartAnnotationProcessor.onError(String parentTxId, String compensationMethod, Throwable throwable)", "constructor": false, "full_signature": "@Override public void onError(String parentTxId, String compensationMethod, Throwable throwable)", "identifier": "onError", "modifiers": "@Override public", "parameters": "(String parentTxId, String compensationMethod, Throwable throwable)", "return": "void", "signature": "void onError(String parentTxId, String compensationMethod, Throwable throwable)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message) {\n try {\n return sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout, omegaContext.category()));\n } catch (OmegaException e) {\n throw new TransactionalException(e.getMessage(), e.getCause());\n }\n }", "class_method_signature": "SagaStartAnnotationProcessor.preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "constructor": false, "full_signature": "@Override public AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "identifier": "preIntercept", "invocations": [ "send", "globalTxId", "localTxId", "category", "getMessage", "getCause" ], "modifiers": "@Override public", "parameters": "(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "return": "AlphaResponse", "signature": "AlphaResponse preIntercept(String parentTxId, String compensationMethod, int timeout, String retriesMethod,\n int retries, Object... message)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 13, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 204463745, "size": 9568, "stargazer_count": 27, "stars": null, "updates": null, "url": "https://github.com/actiontech/txle" }
204463745_17
{ "fields": [], "file": "omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java", "identifier": "LoadBalancedClusterMessageSenderTest", "interfaces": "", "superclass": "extends LoadBalancedClusterMessageSenderTestBase" }
{ "body": "@Test\n public void swallowException_UntilAllSendersConnected() throws Exception {\n MessageSender underlying1 = Mockito.mock(MessageSender.class);\n doThrow(RuntimeException.class).when(underlying1).onConnected();\n\n MessageSender underlying2 = Mockito.mock(MessageSender.class);\n\n MessageSender sender = new LoadBalancedClusterMessageSender(underlying1, underlying2);\n\n sender.onConnected();\n\n verify(underlying1).onConnected();\n verify(underlying2).onConnected();\n }", "class_method_signature": "LoadBalancedClusterMessageSenderTest.swallowException_UntilAllSendersConnected()", "constructor": false, "full_signature": "@Test public void swallowException_UntilAllSendersConnected()", "identifier": "swallowException_UntilAllSendersConnected", "invocations": [ "mock", "onConnected", "when", "doThrow", "mock", "onConnected", "onConnected", "verify", "onConnected", "verify" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void swallowException_UntilAllSendersConnected()", "testcase": true }
{ "fields": [ { "declarator": "LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass())", "modifier": "private static final", "original_string": "private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());", "type": "Logger", "var_name": "LOG" }, { "declarator": "senders = new ConcurrentHashMap<>(8)", "modifier": "private final", "original_string": "private final Map<MessageSender, Long> senders = new ConcurrentHashMap<>(8);", "type": "Map<MessageSender, Long>", "var_name": "senders" }, { "declarator": "channels", "modifier": "private final", "original_string": "private final Collection<ManagedChannel> channels;", "type": "Collection<ManagedChannel>", "var_name": "channels" }, { "declarator": "pendingTasks = new LinkedBlockingQueue<>()", "modifier": "private final", "original_string": "private final BlockingQueue<Runnable> pendingTasks = new LinkedBlockingQueue<>();", "type": "BlockingQueue<Runnable>", "var_name": "pendingTasks" }, { "declarator": "availableMessageSenders = new LinkedBlockingQueue<>()", "modifier": "private final", "original_string": "private final BlockingQueue<MessageSender> availableMessageSenders = new LinkedBlockingQueue<>();", "type": "BlockingQueue<MessageSender>", "var_name": "availableMessageSenders" }, { "declarator": "retryableMessageSender = new RetryableMessageSender(\n availableMessageSenders)", "modifier": "private final", "original_string": "private final MessageSender retryableMessageSender = new RetryableMessageSender(\n availableMessageSenders);", "type": "MessageSender", "var_name": "retryableMessageSender" }, { "declarator": "defaultMessageSender = new Supplier<MessageSender>() {\n @Override\n public MessageSender get() {\n return retryableMessageSender;\n }\n }", "modifier": "private final", "original_string": "private final Supplier<MessageSender> defaultMessageSender = new Supplier<MessageSender>() {\n @Override\n public MessageSender get() {\n return retryableMessageSender;\n }\n };", "type": "Supplier<MessageSender>", "var_name": "defaultMessageSender" }, { "declarator": "scheduler = Executors.newSingleThreadScheduledExecutor()", "modifier": "private final", "original_string": "private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();", "type": "ScheduledExecutorService", "var_name": "scheduler" } ], "file": "omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSender.java", "identifier": "LoadBalancedClusterMessageSender", "interfaces": "implements MessageSender", "methods": [ { "class_method_signature": "LoadBalancedClusterMessageSender.LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "constructor": true, "full_signature": "public LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "identifier": "LoadBalancedClusterMessageSender", "modifiers": "public", "parameters": "(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "return": "", "signature": " LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "constructor": true, "full_signature": " LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "identifier": "LoadBalancedClusterMessageSender", "modifiers": "", "parameters": "(MessageSender... messageSenders)", "return": "", "signature": " LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.onConnected()", "constructor": false, "full_signature": "@Override public void onConnected()", "identifier": "onConnected", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void onConnected()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.onDisconnected()", "constructor": false, "full_signature": "@Override public void onDisconnected()", "identifier": "onDisconnected", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void onDisconnected()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.close()", "constructor": false, "full_signature": "@Override public void close()", "identifier": "close", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void close()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.target()", "constructor": false, "full_signature": "@Override public String target()", "identifier": "target", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String target()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(TxEvent event)", "constructor": false, "full_signature": "@Override public AlphaResponse send(TxEvent event)", "identifier": "send", "modifiers": "@Override public", "parameters": "(TxEvent event)", "return": "AlphaResponse", "signature": "AlphaResponse send(TxEvent event)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(Set<String> localTxIdSet)", "constructor": false, "full_signature": "@Override public Set<String> send(Set<String> localTxIdSet)", "identifier": "send", "modifiers": "@Override public", "parameters": "(Set<String> localTxIdSet)", "return": "Set<String>", "signature": "Set<String> send(Set<String> localTxIdSet)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.reportMessageToServer(KafkaMessage message)", "constructor": false, "full_signature": "@Override public String reportMessageToServer(KafkaMessage message)", "identifier": "reportMessageToServer", "modifiers": "@Override public", "parameters": "(KafkaMessage message)", "return": "String", "signature": "String reportMessageToServer(KafkaMessage message)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.reportAccidentToServer(AccidentHandling accidentHandling)", "constructor": false, "full_signature": "@Override public String reportAccidentToServer(AccidentHandling accidentHandling)", "identifier": "reportAccidentToServer", "modifiers": "@Override public", "parameters": "(AccidentHandling accidentHandling)", "return": "String", "signature": "String reportAccidentToServer(AccidentHandling accidentHandling)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.readConfigFromServer(int type, String category)", "constructor": false, "full_signature": "@Override public GrpcConfigAck readConfigFromServer(int type, String category)", "identifier": "readConfigFromServer", "modifiers": "@Override public", "parameters": "(int type, String category)", "return": "GrpcConfigAck", "signature": "GrpcConfigAck readConfigFromServer(int type, String category)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(String method, Object... args)", "constructor": false, "full_signature": "private Object send(String method, Object... args)", "identifier": "send", "modifiers": "private", "parameters": "(String method, Object... args)", "return": "Object", "signature": "Object send(String method, Object... args)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.scheduleReconnectTask(int reconnectDelay)", "constructor": false, "full_signature": "private void scheduleReconnectTask(int reconnectDelay)", "identifier": "scheduleReconnectTask", "modifiers": "private", "parameters": "(int reconnectDelay)", "return": "void", "signature": "void scheduleReconnectTask(int reconnectDelay)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.buildSslContext(AlphaClusterConfig clusterConfig)", "constructor": false, "full_signature": "private static SslContext buildSslContext(AlphaClusterConfig clusterConfig)", "identifier": "buildSslContext", "modifiers": "private static", "parameters": "(AlphaClusterConfig clusterConfig)", "return": "SslContext", "signature": "SslContext buildSslContext(AlphaClusterConfig clusterConfig)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public void onConnected() {\n for (MessageSender sender : senders.keySet()) {\n try {\n sender.onConnected();\n } catch (Exception e) {\n LOG.error(\"Failed connecting to alpha at {}\", sender.target(), e);\n }\n }\n }", "class_method_signature": "LoadBalancedClusterMessageSender.onConnected()", "constructor": false, "full_signature": "@Override public void onConnected()", "identifier": "onConnected", "invocations": [ "keySet", "onConnected", "error", "target" ], "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void onConnected()", "testcase": false }
{ "created": null, "fork": null, "fork_count": 13, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 204463745, "size": 9568, "stargazer_count": 27, "stars": null, "updates": null, "url": "https://github.com/actiontech/txle" }
204463745_37
{ "fields": [ { "declarator": "messages = new ArrayList<>()", "modifier": "private final", "original_string": "private final List<TxEvent> messages = new ArrayList<>();", "type": "List<TxEvent>", "var_name": "messages" }, { "declarator": "globalTxId = UUID.randomUUID().toString()", "modifier": "private final", "original_string": "private final String globalTxId = UUID.randomUUID().toString();", "type": "String", "var_name": "globalTxId" }, { "declarator": "localTxId = UUID.randomUUID().toString()", "modifier": "private final", "original_string": "private final String localTxId = UUID.randomUUID().toString();", "type": "String", "var_name": "localTxId" }, { "declarator": "parentTxId = UUID.randomUUID().toString()", "modifier": "private final", "original_string": "private final String parentTxId = UUID.randomUUID().toString();", "type": "String", "var_name": "parentTxId" }, { "declarator": "newLocalTxId = UUID.randomUUID().toString()", "modifier": "private final", "original_string": "private final String newLocalTxId = UUID.randomUUID().toString();", "type": "String", "var_name": "newLocalTxId" }, { "declarator": "oops = new RuntimeException(\"oops\")", "modifier": "private final", "original_string": "private final RuntimeException oops = new RuntimeException(\"oops\");", "type": "RuntimeException", "var_name": "oops" }, { "declarator": "idGenerator = mock(IdGenerator.class)", "modifier": "@SuppressWarnings(\"unchecked\")\n private final", "original_string": "@SuppressWarnings(\"unchecked\")\n private final IdGenerator<String> idGenerator = mock(IdGenerator.class);", "type": "IdGenerator<String>", "var_name": "idGenerator" }, { "declarator": "omegaContext = new OmegaContext(idGenerator)", "modifier": "private final", "original_string": "private final OmegaContext omegaContext = new OmegaContext(idGenerator);", "type": "OmegaContext", "var_name": "omegaContext" }, { "declarator": "joinPoint = mock(ProceedingJoinPoint.class)", "modifier": "private final", "original_string": "private final ProceedingJoinPoint joinPoint = mock(ProceedingJoinPoint.class);", "type": "ProceedingJoinPoint", "var_name": "joinPoint" }, { "declarator": "methodSignature = mock(MethodSignature.class)", "modifier": "private final", "original_string": "private final MethodSignature methodSignature = mock(MethodSignature.class);", "type": "MethodSignature", "var_name": "methodSignature" }, { "declarator": "compensable = mock(Compensable.class)", "modifier": "private final", "original_string": "private final Compensable compensable = mock(Compensable.class);", "type": "Compensable", "var_name": "compensable" }, { "declarator": "sender = new MessageSender() {\n @Override\n public void onConnected() {\n\n }\n\n @Override\n public void onDisconnected() {\n\n }\n\n @Override\n public void close() {\n\n }\n\n @Override\n public String target() {\n return \"UNKNOWN\";\n }\n\n @Override\n public AlphaResponse send(TxEvent event) {\n messages.add(event);\n return new AlphaResponse(false);\n }\n\n @Override\n public Set<String> send(Set<String> localTxIdSet) {\n return null;\n }\n\n @Override\n public String reportMessageToServer(KafkaMessage message) {\n return \"\";\n }\n\n @Override\n public String reportAccidentToServer(AccidentHandling accidentHandling) {\n return null;\n }\n\n @Override\n public GrpcConfigAck readConfigFromServer(int type, String category) {\n return null;\n }\n }", "modifier": "private final", "original_string": "private final MessageSender sender = new MessageSender() {\n @Override\n public void onConnected() {\n\n }\n\n @Override\n public void onDisconnected() {\n\n }\n\n @Override\n public void close() {\n\n }\n\n @Override\n public String target() {\n return \"UNKNOWN\";\n }\n\n @Override\n public AlphaResponse send(TxEvent event) {\n messages.add(event);\n return new AlphaResponse(false);\n }\n\n @Override\n public Set<String> send(Set<String> localTxIdSet) {\n return null;\n }\n\n @Override\n public String reportMessageToServer(KafkaMessage message) {\n return \"\";\n }\n\n @Override\n public String reportAccidentToServer(AccidentHandling accidentHandling) {\n return null;\n }\n\n @Override\n public GrpcConfigAck readConfigFromServer(int type, String category) {\n return null;\n }\n };", "type": "MessageSender", "var_name": "sender" }, { "declarator": "interceptor = new CompensableInterceptor(omegaContext, sender)", "modifier": "private final", "original_string": "private final CompensableInterceptor interceptor = new CompensableInterceptor(omegaContext, sender);", "type": "CompensableInterceptor", "var_name": "interceptor" }, { "declarator": "recoveryPolicy = new DefaultRecovery()", "modifier": "private final", "original_string": "private final RecoveryPolicy recoveryPolicy = new DefaultRecovery();", "type": "RecoveryPolicy", "var_name": "recoveryPolicy" } ], "file": "omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecoveryTest.java", "identifier": "DefaultRecoveryTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void recordAbortedEventWhenFailed() throws Throwable {\n when(joinPoint.proceed()).thenThrow(oops);\n\n try {\n recoveryPolicy.apply(joinPoint, compensable, interceptor, omegaContext, parentTxId, 0);\n expectFailing(RuntimeException.class);\n } catch (RuntimeException e) {\n assertThat(e.getMessage(), is(\"oops\"));\n }\n\n assertThat(messages.size(), is(2));\n\n TxEvent startedEvent = messages.get(0);\n assertThat(startedEvent.globalTxId(), is(globalTxId));\n assertThat(startedEvent.localTxId(), is(localTxId));\n assertThat(startedEvent.parentTxId(), is(parentTxId));\n assertThat(startedEvent.type(), is(EventType.TxStartedEvent));\n assertThat(startedEvent.retries(), is(0));\n assertThat(startedEvent.retryMethod(), is(\"\"));\n\n TxEvent abortedEvent = messages.get(1);\n assertThat(abortedEvent.globalTxId(), is(globalTxId));\n assertThat(abortedEvent.localTxId(), is(localTxId));\n assertThat(abortedEvent.parentTxId(), is(parentTxId));\n assertThat(abortedEvent.type(), is(EventType.TxAbortedEvent));\n }", "class_method_signature": "DefaultRecoveryTest.recordAbortedEventWhenFailed()", "constructor": false, "full_signature": "@Test public void recordAbortedEventWhenFailed()", "identifier": "recordAbortedEventWhenFailed", "invocations": [ "thenThrow", "when", "proceed", "apply", "expectFailing", "assertThat", "getMessage", "is", "assertThat", "size", "is", "get", "assertThat", "globalTxId", "is", "assertThat", "localTxId", "is", "assertThat", "parentTxId", "is", "assertThat", "type", "is", "assertThat", "retries", "is", "assertThat", "retryMethod", "is", "get", "assertThat", "globalTxId", "is", "assertThat", "localTxId", "is", "assertThat", "parentTxId", "is", "assertThat", "type", "is" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void recordAbortedEventWhenFailed()", "testcase": true }
{ "fields": [ { "declarator": "LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass())", "modifier": "private static final", "original_string": "private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());", "type": "Logger", "var_name": "LOG" } ], "file": "omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java", "identifier": "DefaultRecovery", "interfaces": "implements RecoveryPolicy", "methods": [ { "class_method_signature": "DefaultRecovery.apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "constructor": false, "full_signature": "@Override public Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "identifier": "apply", "modifiers": "@Override public", "parameters": "(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "return": "Object", "signature": "Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "testcase": false }, { "class_method_signature": "DefaultRecovery.compensationMethodSignature(ProceedingJoinPoint joinPoint, Compensable compensable, Method method)", "constructor": false, "full_signature": " String compensationMethodSignature(ProceedingJoinPoint joinPoint, Compensable compensable, Method method)", "identifier": "compensationMethodSignature", "modifiers": "", "parameters": "(ProceedingJoinPoint joinPoint, Compensable compensable, Method method)", "return": "String", "signature": "String compensationMethodSignature(ProceedingJoinPoint joinPoint, Compensable compensable, Method method)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries) throws Throwable {\n Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();\n LOG.debug(\"Intercepting compensable method {} with context {}\", method.toString(), context);\n String compensationSignature = compensable.compensationMethod().isEmpty() ? \"\" : compensationMethodSignature(joinPoint, compensable, method);\n String retrySignature = (retries != 0 || compensationSignature.isEmpty()) ? method.toString() : \"\";\n boolean isProceed = false;\n boolean enabledTx = false;\n\n try {\n // Recoding current thread identify, globalTxId and localTxId, the aim is to relate auto-compensation SQL by current thread identify. By Gannalyo\n CurrentThreadOmegaContext.putThreadGlobalLocalTxId(new OmegaContextServiceConfig(context, false, false));\n\n AlphaResponse response = interceptor.preIntercept(parentTxId, compensationSignature, compensable.timeout(), retrySignature, retries, joinPoint.getArgs());\n enabledTx = response.enabledTx();\n\n isProceed = true;\n Object result = null;\n if (!response.aborted()) {\n result = joinPoint.proceed();\n }\n\n if (enabledTx) {\n if (response.aborted()) {\n String abortedLocalTxId = context.localTxId();\n context.setLocalTxId(parentTxId);\n throw new InvalidTransactionException(\"Abort sub transaction \" + abortedLocalTxId + \" because global transaction \" + context.globalTxId() + \" has already aborted.\");\n }\n\n CurrentThreadOmegaContext.clearCache();\n interceptor.postIntercept(parentTxId, compensationSignature);\n }\n\n return result;\n } catch (InvalidTransactionException ite) {\n throw ite;\n } catch (Throwable throwable) {\n boolean isFaultTolerant = ApplicationContextUtil.getApplicationContext().getBean(MessageSender.class).readConfigFromServer(ConfigCenterType.CompensationFaultTolerant.toInteger(), context.category()).getStatus();\n if (enabledTx && !isFaultTolerant) {\n interceptor.onError(parentTxId, compensationSignature, throwable);\n }\n\n // In case of exception, to execute business if it is not proceed yet when the fault-tolerant degradation is enabled fro global transaction.\n if (!isProceed && isFaultTolerant) {\n return joinPoint.proceed();\n }\n throw throwable;\n }\n }", "class_method_signature": "DefaultRecovery.apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "constructor": false, "full_signature": "@Override public Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "identifier": "apply", "invocations": [ "getMethod", "getSignature", "debug", "toString", "isEmpty", "compensationMethod", "compensationMethodSignature", "isEmpty", "toString", "putThreadGlobalLocalTxId", "preIntercept", "timeout", "getArgs", "enabledTx", "aborted", "proceed", "aborted", "localTxId", "setLocalTxId", "globalTxId", "clearCache", "postIntercept", "getStatus", "readConfigFromServer", "getBean", "getApplicationContext", "toInteger", "category", "onError", "proceed" ], "modifiers": "@Override public", "parameters": "(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "return": "Object", "signature": "Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,\n OmegaContext context, String parentTxId, int retries)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 13, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 204463745, "size": 9568, "stargazer_count": 27, "stars": null, "updates": null, "url": "https://github.com/actiontech/txle" }
204463745_21
{ "fields": [], "file": "omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java", "identifier": "LoadBalancedClusterMessageSenderTest", "interfaces": "", "superclass": "extends LoadBalancedClusterMessageSenderTestBase" }
{ "body": "@Test\n public void blowsUpWhenServerIsInterrupted() throws InterruptedException {\n Thread thread = new Thread(new Runnable() {\n @Override\n public void run() {\n try {\n messageSender.send(event);\n expectFailing(OmegaException.class);\n } catch (OmegaException e) {\n assertThat(e.getMessage().endsWith(\"interruption\"), is(true));\n }\n }\n });\n\n thread.start();\n thread.interrupt();\n thread.join();\n }", "class_method_signature": "LoadBalancedClusterMessageSenderTest.blowsUpWhenServerIsInterrupted()", "constructor": false, "full_signature": "@Test public void blowsUpWhenServerIsInterrupted()", "identifier": "blowsUpWhenServerIsInterrupted", "invocations": [ "send", "expectFailing", "assertThat", "endsWith", "getMessage", "is", "start", "interrupt", "join" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void blowsUpWhenServerIsInterrupted()", "testcase": true }
{ "fields": [ { "declarator": "LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass())", "modifier": "private static final", "original_string": "private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());", "type": "Logger", "var_name": "LOG" }, { "declarator": "senders = new ConcurrentHashMap<>(8)", "modifier": "private final", "original_string": "private final Map<MessageSender, Long> senders = new ConcurrentHashMap<>(8);", "type": "Map<MessageSender, Long>", "var_name": "senders" }, { "declarator": "channels", "modifier": "private final", "original_string": "private final Collection<ManagedChannel> channels;", "type": "Collection<ManagedChannel>", "var_name": "channels" }, { "declarator": "pendingTasks = new LinkedBlockingQueue<>()", "modifier": "private final", "original_string": "private final BlockingQueue<Runnable> pendingTasks = new LinkedBlockingQueue<>();", "type": "BlockingQueue<Runnable>", "var_name": "pendingTasks" }, { "declarator": "availableMessageSenders = new LinkedBlockingQueue<>()", "modifier": "private final", "original_string": "private final BlockingQueue<MessageSender> availableMessageSenders = new LinkedBlockingQueue<>();", "type": "BlockingQueue<MessageSender>", "var_name": "availableMessageSenders" }, { "declarator": "retryableMessageSender = new RetryableMessageSender(\n availableMessageSenders)", "modifier": "private final", "original_string": "private final MessageSender retryableMessageSender = new RetryableMessageSender(\n availableMessageSenders);", "type": "MessageSender", "var_name": "retryableMessageSender" }, { "declarator": "defaultMessageSender = new Supplier<MessageSender>() {\n @Override\n public MessageSender get() {\n return retryableMessageSender;\n }\n }", "modifier": "private final", "original_string": "private final Supplier<MessageSender> defaultMessageSender = new Supplier<MessageSender>() {\n @Override\n public MessageSender get() {\n return retryableMessageSender;\n }\n };", "type": "Supplier<MessageSender>", "var_name": "defaultMessageSender" }, { "declarator": "scheduler = Executors.newSingleThreadScheduledExecutor()", "modifier": "private final", "original_string": "private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();", "type": "ScheduledExecutorService", "var_name": "scheduler" } ], "file": "omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSender.java", "identifier": "LoadBalancedClusterMessageSender", "interfaces": "implements MessageSender", "methods": [ { "class_method_signature": "LoadBalancedClusterMessageSender.LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "constructor": true, "full_signature": "public LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "identifier": "LoadBalancedClusterMessageSender", "modifiers": "public", "parameters": "(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "return": "", "signature": " LoadBalancedClusterMessageSender(AlphaClusterConfig clusterConfig,\n MessageSerializer serializer,\n MessageDeserializer deserializer,\n ServiceConfig serviceConfig,\n MessageHandler handler,\n int reconnectDelay,\n Tracing tracing)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "constructor": true, "full_signature": " LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "identifier": "LoadBalancedClusterMessageSender", "modifiers": "", "parameters": "(MessageSender... messageSenders)", "return": "", "signature": " LoadBalancedClusterMessageSender(MessageSender... messageSenders)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.onConnected()", "constructor": false, "full_signature": "@Override public void onConnected()", "identifier": "onConnected", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void onConnected()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.onDisconnected()", "constructor": false, "full_signature": "@Override public void onDisconnected()", "identifier": "onDisconnected", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void onDisconnected()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.close()", "constructor": false, "full_signature": "@Override public void close()", "identifier": "close", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void close()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.target()", "constructor": false, "full_signature": "@Override public String target()", "identifier": "target", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String target()", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(TxEvent event)", "constructor": false, "full_signature": "@Override public AlphaResponse send(TxEvent event)", "identifier": "send", "modifiers": "@Override public", "parameters": "(TxEvent event)", "return": "AlphaResponse", "signature": "AlphaResponse send(TxEvent event)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(Set<String> localTxIdSet)", "constructor": false, "full_signature": "@Override public Set<String> send(Set<String> localTxIdSet)", "identifier": "send", "modifiers": "@Override public", "parameters": "(Set<String> localTxIdSet)", "return": "Set<String>", "signature": "Set<String> send(Set<String> localTxIdSet)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.reportMessageToServer(KafkaMessage message)", "constructor": false, "full_signature": "@Override public String reportMessageToServer(KafkaMessage message)", "identifier": "reportMessageToServer", "modifiers": "@Override public", "parameters": "(KafkaMessage message)", "return": "String", "signature": "String reportMessageToServer(KafkaMessage message)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.reportAccidentToServer(AccidentHandling accidentHandling)", "constructor": false, "full_signature": "@Override public String reportAccidentToServer(AccidentHandling accidentHandling)", "identifier": "reportAccidentToServer", "modifiers": "@Override public", "parameters": "(AccidentHandling accidentHandling)", "return": "String", "signature": "String reportAccidentToServer(AccidentHandling accidentHandling)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.readConfigFromServer(int type, String category)", "constructor": false, "full_signature": "@Override public GrpcConfigAck readConfigFromServer(int type, String category)", "identifier": "readConfigFromServer", "modifiers": "@Override public", "parameters": "(int type, String category)", "return": "GrpcConfigAck", "signature": "GrpcConfigAck readConfigFromServer(int type, String category)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.send(String method, Object... args)", "constructor": false, "full_signature": "private Object send(String method, Object... args)", "identifier": "send", "modifiers": "private", "parameters": "(String method, Object... args)", "return": "Object", "signature": "Object send(String method, Object... args)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.scheduleReconnectTask(int reconnectDelay)", "constructor": false, "full_signature": "private void scheduleReconnectTask(int reconnectDelay)", "identifier": "scheduleReconnectTask", "modifiers": "private", "parameters": "(int reconnectDelay)", "return": "void", "signature": "void scheduleReconnectTask(int reconnectDelay)", "testcase": false }, { "class_method_signature": "LoadBalancedClusterMessageSender.buildSslContext(AlphaClusterConfig clusterConfig)", "constructor": false, "full_signature": "private static SslContext buildSslContext(AlphaClusterConfig clusterConfig)", "identifier": "buildSslContext", "modifiers": "private static", "parameters": "(AlphaClusterConfig clusterConfig)", "return": "SslContext", "signature": "SslContext buildSslContext(AlphaClusterConfig clusterConfig)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public AlphaResponse send(TxEvent event) {\n return (AlphaResponse) send(\"sendEvent\", event);\n }", "class_method_signature": "LoadBalancedClusterMessageSender.send(TxEvent event)", "constructor": false, "full_signature": "@Override public AlphaResponse send(TxEvent event)", "identifier": "send", "invocations": [ "send" ], "modifiers": "@Override public", "parameters": "(TxEvent event)", "return": "AlphaResponse", "signature": "AlphaResponse send(TxEvent event)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 13, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 204463745, "size": 9568, "stargazer_count": 27, "stars": null, "updates": null, "url": "https://github.com/actiontech/txle" }
225191103_0
{ "fields": [], "file": "exercise3/src/test/java/org/example/exercise3/GreetingResourceTest.java", "identifier": "GreetingResourceTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testGetOne() {\n given()\n .when().get(\"/greeting/1\")\n .then()\n .statusCode(200)\n .body(is(\"Salut\"));\n }", "class_method_signature": "GreetingResourceTest.testGetOne()", "constructor": false, "full_signature": "@Test public void testGetOne()", "identifier": "testGetOne", "invocations": [ "body", "statusCode", "then", "get", "when", "given", "is" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testGetOne()", "testcase": true }
{ "fields": [ { "declarator": "service", "modifier": "@Inject", "original_string": "@Inject\n GreetingService service;", "type": "GreetingService", "var_name": "service" } ], "file": "exercise3/src/main/java/org/example/exercise3/GreetingResource.java", "identifier": "GreetingResource", "interfaces": "", "methods": [ { "class_method_signature": "GreetingResource.getAll()", "constructor": false, "full_signature": "@GET public List<String> getAll()", "identifier": "getAll", "modifiers": "@GET public", "parameters": "()", "return": "List<String>", "signature": "List<String> getAll()", "testcase": false }, { "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false } ], "superclass": "" }
{ "body": "@GET\n @Path(\"/{id}\")\n public Response getOne(@PathParam(\"id\") Long id) {\n String entity = service.get(id.intValue());\n if (entity == null) {\n return Response\n .status(Response.Status.NOT_FOUND)\n .build();\n }\n return Response\n .status(Response.Status.OK)\n .entity(entity)\n .build();\n }", "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "invocations": [ "get", "intValue", "build", "status", "build", "entity", "status" ], "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 14, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 225191103, "size": 140, "stargazer_count": 17, "stars": null, "updates": null, "url": "https://github.com/prpatel/quarkus-workshop" }
225191103_1
{ "fields": [], "file": "exercise5/src/test/java/org/example/exercise5/GreetingResourceTest.java", "identifier": "GreetingResourceTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testGetOne() {\n given()\n .when().get(\"/greeting/1\")\n .then()\n .statusCode(200)\n .body(is(\"Salut\"));\n }", "class_method_signature": "GreetingResourceTest.testGetOne()", "constructor": false, "full_signature": "@Test public void testGetOne()", "identifier": "testGetOne", "invocations": [ "body", "statusCode", "then", "get", "when", "given", "is" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testGetOne()", "testcase": true }
{ "fields": [ { "declarator": "service", "modifier": "@Inject", "original_string": "@Inject\n GreetingService service;", "type": "GreetingService", "var_name": "service" } ], "file": "exercise5/src/main/java/org/example/exercise5/GreetingResource.java", "identifier": "GreetingResource", "interfaces": "", "methods": [ { "class_method_signature": "GreetingResource.getAll()", "constructor": false, "full_signature": "@GET @Produces(MediaType.TEXT_PLAIN) public List<String> getAll()", "identifier": "getAll", "modifiers": "@GET @Produces(MediaType.TEXT_PLAIN) public", "parameters": "()", "return": "List<String>", "signature": "List<String> getAll()", "testcase": false }, { "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false } ], "superclass": "" }
{ "body": "@GET\n @Path(\"/{id}\")\n public Response getOne(@PathParam(\"id\") Long id) {\n String entity = service.get(id.intValue());\n if (entity == null) {\n return Response\n .status(Response.Status.NOT_FOUND)\n .build();\n }\n return Response\n .status(Response.Status.OK)\n .entity(entity)\n .build();\n }", "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "invocations": [ "get", "intValue", "build", "status", "build", "entity", "status" ], "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 14, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 225191103, "size": 140, "stargazer_count": 17, "stars": null, "updates": null, "url": "https://github.com/prpatel/quarkus-workshop" }
225191103_4
{ "fields": [ { "declarator": "somevar = false", "modifier": "public", "original_string": "public boolean somevar = false;", "type": "boolean", "var_name": "somevar" } ], "file": "exercise7/src/test/java/com/thejavacafe/backend/ArticleResourceTest.java", "identifier": "ArticleResourceTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n @Order(1)\n void testGetOne() {\n\n given()\n .pathParam(\"id\", \"1\")\n .when()\n .get(\"/article/{id}\")\n .then()\n// .log().body()\n .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)\n .statusCode(HttpStatus.SC_OK)\n .body(\"title\", equalTo(\"Test Article\"));\n\n }", "class_method_signature": "ArticleResourceTest.testGetOne()", "constructor": false, "full_signature": "@Test @Order(1) void testGetOne()", "identifier": "testGetOne", "invocations": [ "body", "statusCode", "header", "then", "get", "when", "pathParam", "given", "equalTo" ], "modifiers": "@Test @Order(1)", "parameters": "()", "return": "void", "signature": "void testGetOne()", "testcase": true }
{ "fields": [ { "declarator": "emails", "modifier": "@Inject\n @Stream(\"emails\")", "original_string": "@Inject\n @Stream(\"emails\") // Emit on the channel 'emails'\n Emitter<String> emails;", "type": "Emitter<String>", "var_name": "emails" } ], "file": "exercise7/src/main/java/com/thejavacafe/backend/ArticleResource.java", "identifier": "ArticleResource", "interfaces": "", "methods": [ { "class_method_signature": "ArticleResource.opt()", "constructor": false, "full_signature": "@OPTIONS public Response opt()", "identifier": "opt", "modifiers": "@OPTIONS public", "parameters": "()", "return": "Response", "signature": "Response opt()", "testcase": false }, { "class_method_signature": "ArticleResource.getAll(@QueryParam(\"page\") Integer page)", "constructor": false, "full_signature": "@GET public List<Article> getAll(@QueryParam(\"page\") Integer page)", "identifier": "getAll", "modifiers": "@GET public", "parameters": "(@QueryParam(\"page\") Integer page)", "return": "List<Article>", "signature": "List<Article> getAll(@QueryParam(\"page\") Integer page)", "testcase": false }, { "class_method_signature": "ArticleResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }, { "class_method_signature": "ArticleResource.create(Article article)", "constructor": false, "full_signature": "@POST @Transactional public Response create(Article article)", "identifier": "create", "modifiers": "@POST @Transactional public", "parameters": "(Article article)", "return": "Response", "signature": "Response create(Article article)", "testcase": false }, { "class_method_signature": "ArticleResource.update(Article article, @PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@PUT @Path(\"/{id}\") @Transactional public Response update(Article article, @PathParam(\"id\") Long id)", "identifier": "update", "modifiers": "@PUT @Path(\"/{id}\") @Transactional public", "parameters": "(Article article, @PathParam(\"id\") Long id)", "return": "Response", "signature": "Response update(Article article, @PathParam(\"id\") Long id)", "testcase": false }, { "class_method_signature": "ArticleResource.deleteOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@DELETE @Transactional @Path(\"/{id}\") public Response deleteOne(@PathParam(\"id\") Long id)", "identifier": "deleteOne", "modifiers": "@DELETE @Transactional @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response deleteOne(@PathParam(\"id\") Long id)", "testcase": false } ], "superclass": "" }
{ "body": "@GET\n @Path(\"/{id}\")\n public Response getOne(@PathParam(\"id\") Long id) {\n Article entity = Article.findById(id);\n if (entity == null) {\n return Response\n .status(Response.Status.NOT_FOUND)\n .build();\n }\n\n return Response\n .status(Response.Status.OK)\n .entity(entity)\n .build();\n }", "class_method_signature": "ArticleResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "invocations": [ "findById", "build", "status", "build", "entity", "status" ], "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 14, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 225191103, "size": 140, "stargazer_count": 17, "stars": null, "updates": null, "url": "https://github.com/prpatel/quarkus-workshop" }
225191103_2
{ "fields": [], "file": "exercise4/src/test/java/org/example/exercise4/GreetingResourceTest.java", "identifier": "GreetingResourceTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testGetOne() {\n given()\n .when().get(\"/greeting/1\")\n .then()\n .statusCode(200)\n .body(is(\"Salut\"));\n }", "class_method_signature": "GreetingResourceTest.testGetOne()", "constructor": false, "full_signature": "@Test public void testGetOne()", "identifier": "testGetOne", "invocations": [ "body", "statusCode", "then", "get", "when", "given", "is" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testGetOne()", "testcase": true }
{ "fields": [ { "declarator": "service", "modifier": "@Inject", "original_string": "@Inject\n GreetingService service;", "type": "GreetingService", "var_name": "service" } ], "file": "exercise4/src/main/java/org/example/exercise4/GreetingResource.java", "identifier": "GreetingResource", "interfaces": "", "methods": [ { "class_method_signature": "GreetingResource.getAll()", "constructor": false, "full_signature": "@GET public List<String> getAll()", "identifier": "getAll", "modifiers": "@GET public", "parameters": "()", "return": "List<String>", "signature": "List<String> getAll()", "testcase": false }, { "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }, { "class_method_signature": "GreetingResource.create(String name)", "constructor": false, "full_signature": "@POST public Response create(String name)", "identifier": "create", "modifiers": "@POST public", "parameters": "(String name)", "return": "Response", "signature": "Response create(String name)", "testcase": false }, { "class_method_signature": "GreetingResource.update(String name, @PathParam(\"id\") int id)", "constructor": false, "full_signature": "@PUT @Path(\"/{id}\") public Response update(String name, @PathParam(\"id\") int id)", "identifier": "update", "modifiers": "@PUT @Path(\"/{id}\") public", "parameters": "(String name, @PathParam(\"id\") int id)", "return": "Response", "signature": "Response update(String name, @PathParam(\"id\") int id)", "testcase": false }, { "class_method_signature": "GreetingResource.deleteOne(@PathParam(\"id\") int id)", "constructor": false, "full_signature": "@DELETE @Path(\"/{id}\") public Response deleteOne(@PathParam(\"id\") int id)", "identifier": "deleteOne", "modifiers": "@DELETE @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") int id)", "return": "Response", "signature": "Response deleteOne(@PathParam(\"id\") int id)", "testcase": false } ], "superclass": "" }
{ "body": "@GET\n @Path(\"/{id}\")\n public Response getOne(@PathParam(\"id\") Long id) {\n String entity = service.get(id.intValue());\n if (entity == null) {\n return Response\n .status(Response.Status.NOT_FOUND)\n .build();\n }\n return Response\n .status(Response.Status.OK)\n .entity(entity)\n .build();\n }", "class_method_signature": "GreetingResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "invocations": [ "get", "intValue", "build", "status", "build", "entity", "status" ], "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 14, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 225191103, "size": 140, "stargazer_count": 17, "stars": null, "updates": null, "url": "https://github.com/prpatel/quarkus-workshop" }
225191103_3
{ "fields": [ { "declarator": "somevar = false", "modifier": "public", "original_string": "public boolean somevar = false;", "type": "boolean", "var_name": "somevar" } ], "file": "exercise7/src/test/java/com/thejavacafe/backend/TagResourceTest.java", "identifier": "TagResourceTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n @Order(1)\n void testGetOne() {\n\n given()\n .pathParam(\"id\", \"15\")\n .when()\n .get(\"/tag/{id}\")\n .then()\n// .log().body()\n .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)\n .statusCode(HttpStatus.SC_OK)\n .body(\"name\", equalTo(\"Cloud\"));\n\n }", "class_method_signature": "TagResourceTest.testGetOne()", "constructor": false, "full_signature": "@Test @Order(1) void testGetOne()", "identifier": "testGetOne", "invocations": [ "body", "statusCode", "header", "then", "get", "when", "pathParam", "given", "equalTo" ], "modifiers": "@Test @Order(1)", "parameters": "()", "return": "void", "signature": "void testGetOne()", "testcase": true }
{ "fields": [], "file": "exercise7/src/main/java/com/thejavacafe/backend/TagResource.java", "identifier": "TagResource", "interfaces": "", "methods": [ { "class_method_signature": "TagResource.opt()", "constructor": false, "full_signature": "@OPTIONS public Response opt()", "identifier": "opt", "modifiers": "@OPTIONS public", "parameters": "()", "return": "Response", "signature": "Response opt()", "testcase": false }, { "class_method_signature": "TagResource.getAll()", "constructor": false, "full_signature": "@GET public List<Tag> getAll()", "identifier": "getAll", "modifiers": "@GET public", "parameters": "()", "return": "List<Tag>", "signature": "List<Tag> getAll()", "testcase": false }, { "class_method_signature": "TagResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }, { "class_method_signature": "TagResource.create(Tag tag)", "constructor": false, "full_signature": "@POST @Transactional public Response create(Tag tag)", "identifier": "create", "modifiers": "@POST @Transactional public", "parameters": "(Tag tag)", "return": "Response", "signature": "Response create(Tag tag)", "testcase": false }, { "class_method_signature": "TagResource.update(Tag tag, @PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@PUT @Path(\"/{id}\") @Transactional public Response update(Tag tag, @PathParam(\"id\") Long id)", "identifier": "update", "modifiers": "@PUT @Path(\"/{id}\") @Transactional public", "parameters": "(Tag tag, @PathParam(\"id\") Long id)", "return": "Response", "signature": "Response update(Tag tag, @PathParam(\"id\") Long id)", "testcase": false }, { "class_method_signature": "TagResource.deleteOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@DELETE @Transactional @Path(\"/{id}\") public Response deleteOne(@PathParam(\"id\") Long id)", "identifier": "deleteOne", "modifiers": "@DELETE @Transactional @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response deleteOne(@PathParam(\"id\") Long id)", "testcase": false } ], "superclass": "" }
{ "body": "@GET\n @Path(\"/{id}\")\n public Response getOne(@PathParam(\"id\") Long id) {\n Tag entity = Tag.findById(id);\n if (entity == null) {\n return Response\n .status(Response.Status.NOT_FOUND)\n .build();\n }\n return Response\n .status(Response.Status.OK)\n .entity(entity)\n .build();\n }", "class_method_signature": "TagResource.getOne(@PathParam(\"id\") Long id)", "constructor": false, "full_signature": "@GET @Path(\"/{id}\") public Response getOne(@PathParam(\"id\") Long id)", "identifier": "getOne", "invocations": [ "findById", "build", "status", "build", "entity", "status" ], "modifiers": "@GET @Path(\"/{id}\") public", "parameters": "(@PathParam(\"id\") Long id)", "return": "Response", "signature": "Response getOne(@PathParam(\"id\") Long id)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 14, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 225191103, "size": 140, "stargazer_count": 17, "stars": null, "updates": null, "url": "https://github.com/prpatel/quarkus-workshop" }
158618423_2
{ "fields": [ { "declarator": "TEST_KEY = \"test\"", "modifier": "private static final", "original_string": "private static final String TEST_KEY = \"test\";", "type": "String", "var_name": "TEST_KEY" }, { "declarator": "VALUE_ONE = new byte[] {0xA, 0xB}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_ONE = new byte[] {0xA, 0xB};", "type": "byte[]", "var_name": "VALUE_ONE" }, { "declarator": "VALUE_TWO = new byte[] {0x1, 0x2}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_TWO = new byte[] {0x1, 0x2};", "type": "byte[]", "var_name": "VALUE_TWO" }, { "declarator": "SAMPLE_SCOPE = \"myscope\"", "modifier": "private static final", "original_string": "private static final String SAMPLE_SCOPE = \"myscope\";", "type": "String", "var_name": "SAMPLE_SCOPE" }, { "declarator": "context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()", "modifier": "private", "original_string": "private Context context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();", "type": "Context", "var_name": "context" }, { "declarator": "directoryProvider = new AndroidDirectoryProvider(context)", "modifier": "private final", "original_string": "private final DirectoryProvider directoryProvider = new AndroidDirectoryProvider(context);", "type": "DirectoryProvider", "var_name": "directoryProvider" } ], "file": "simplestore/src/test/java/com/uber/simplestore/impl/SimpleStoreImplTest.java", "identifier": "SimpleStoreImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void clear() throws Exception {\n try (SimpleStore store = SimpleStoreFactory.create(directoryProvider, SAMPLE_SCOPE)) {\n store.put(TEST_KEY, new byte[1]).get();\n store.clear().get();\n ListenableFuture<byte[]> empty = store.get(TEST_KEY);\n assertThat(empty.get()).isEmpty();\n }\n }", "class_method_signature": "SimpleStoreImplTest.clear()", "constructor": false, "full_signature": "@Test public void clear()", "identifier": "clear", "invocations": [ "create", "get", "put", "get", "clear", "get", "isEmpty", "assertThat", "get" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void clear()", "testcase": true }
{ "fields": [ { "declarator": "OPEN = 0", "modifier": "private static final", "original_string": "private static final int OPEN = 0;", "type": "int", "var_name": "OPEN" }, { "declarator": "CLOSED = 1", "modifier": "private static final", "original_string": "private static final int CLOSED = 1;", "type": "int", "var_name": "CLOSED" }, { "declarator": "TOMBSTONED = 2", "modifier": "private static final", "original_string": "private static final int TOMBSTONED = 2;", "type": "int", "var_name": "TOMBSTONED" }, { "declarator": "EMPTY_BYTES = new byte[0]", "modifier": "private static final", "original_string": "private static final byte[] EMPTY_BYTES = new byte[0];", "type": "byte[]", "var_name": "EMPTY_BYTES" }, { "declarator": "STRING_ENCODING = StandardCharsets.UTF_16BE", "modifier": "private static final", "original_string": "private static final Charset STRING_ENCODING = StandardCharsets.UTF_16BE;", "type": "Charset", "var_name": "STRING_ENCODING" }, { "declarator": "namespace", "modifier": "private final", "original_string": "private final String namespace;", "type": "String", "var_name": "namespace" }, { "declarator": "namespacedDirectory", "modifier": "@Nullable private", "original_string": "@Nullable private File namespacedDirectory;", "type": "File", "var_name": "namespacedDirectory" }, { "declarator": "available = new AtomicInteger(OPEN)", "modifier": "", "original_string": "AtomicInteger available = new AtomicInteger(OPEN);", "type": "AtomicInteger", "var_name": "available" }, { "declarator": "cache = new HashMap<>()", "modifier": "private final", "original_string": "private final Map<String, byte[]> cache = new HashMap<>();", "type": "Map<String, byte[]>", "var_name": "cache" }, { "declarator": "orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor())", "modifier": "private final", "original_string": "private final Executor orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor());", "type": "Executor", "var_name": "orderedIoExecutor" }, { "declarator": "flush", "modifier": "@Nullable private", "original_string": "@Nullable private Exception flush;", "type": "Exception", "var_name": "flush" } ], "file": "simplestore/src/main/java/com/uber/simplestore/impl/SimpleStoreImpl.java", "identifier": "SimpleStoreImpl", "interfaces": "implements SimpleStore", "methods": [ { "class_method_signature": "SimpleStoreImpl.SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "constructor": true, "full_signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "identifier": "SimpleStoreImpl", "modifiers": "", "parameters": "(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "return": "", "signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getString(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> getString(String key)", "identifier": "getString", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> getString(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.putString(String key, @Nullable String value)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> putString(String key, @Nullable String value)", "identifier": "putString", "modifiers": "@Override public", "parameters": "(String key, @Nullable String value)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> putString(String key, @Nullable String value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.get(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> get(String key)", "identifier": "get", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> get(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.put(String key, @Nullable byte[] value)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "identifier": "put", "modifiers": "@Override public", "parameters": "(String key, @Nullable byte[] value)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.contains(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Boolean> contains(String key)", "identifier": "contains", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Boolean>", "signature": "ListenableFuture<Boolean> contains(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.remove(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> remove(String key)", "identifier": "remove", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> remove(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clear()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> clear()", "identifier": "clear", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> clear()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteAllNow()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> deleteAllNow()", "identifier": "deleteAllNow", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> deleteAllNow()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clearCache()", "constructor": false, "full_signature": " void clearCache()", "identifier": "clearCache", "modifiers": "", "parameters": "()", "return": "void", "signature": "void clearCache()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.failQueueThenRun(Exception exception, Runnable runnable)", "constructor": false, "full_signature": " void failQueueThenRun(Exception exception, Runnable runnable)", "identifier": "failQueueThenRun", "modifiers": "", "parameters": "(Exception exception, Runnable runnable)", "return": "void", "signature": "void failQueueThenRun(Exception exception, Runnable runnable)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.moveAway()", "constructor": false, "full_signature": " void moveAway()", "identifier": "moveAway", "modifiers": "", "parameters": "()", "return": "void", "signature": "void moveAway()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.recursiveDelete(File directory)", "constructor": false, "full_signature": "private static void recursiveDelete(File directory)", "identifier": "recursiveDelete", "modifiers": "private static", "parameters": "(File directory)", "return": "void", "signature": "void recursiveDelete(File directory)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.close()", "constructor": false, "full_signature": "@Override public void close()", "identifier": "close", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void close()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.requireOpen()", "constructor": false, "full_signature": "private void requireOpen()", "identifier": "requireOpen", "modifiers": "private", "parameters": "()", "return": "void", "signature": "void requireOpen()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getOrderedExecutor()", "constructor": false, "full_signature": "@VisibleForTesting Executor getOrderedExecutor()", "identifier": "getOrderedExecutor", "modifiers": "@VisibleForTesting", "parameters": "()", "return": "Executor", "signature": "Executor getOrderedExecutor()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.tombstone()", "constructor": false, "full_signature": " boolean tombstone()", "identifier": "tombstone", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean tombstone()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getNamespace()", "constructor": false, "full_signature": " String getNamespace()", "identifier": "getNamespace", "modifiers": "", "parameters": "()", "return": "String", "signature": "String getNamespace()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.openIfClosed()", "constructor": false, "full_signature": " boolean openIfClosed()", "identifier": "openIfClosed", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean openIfClosed()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.isDead()", "constructor": false, "full_signature": "@Nullable private Exception isDead()", "identifier": "isDead", "modifiers": "@Nullable private", "parameters": "()", "return": "Exception", "signature": "Exception isDead()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteFile(String key)", "constructor": false, "full_signature": "private void deleteFile(String key)", "identifier": "deleteFile", "modifiers": "private", "parameters": "(String key)", "return": "void", "signature": "void deleteFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.readFile(String key)", "constructor": false, "full_signature": "@Nullable private byte[] readFile(String key)", "identifier": "readFile", "modifiers": "@Nullable private", "parameters": "(String key)", "return": "byte[]", "signature": "byte[] readFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.writeFile(String key, byte[] value)", "constructor": false, "full_signature": "private void writeFile(String key, byte[] value)", "identifier": "writeFile", "modifiers": "private", "parameters": "(String key, byte[] value)", "return": "void", "signature": "void writeFile(String key, byte[] value)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ListenableFuture<Void> clear() {\n requireOpen();\n return Futures.submitAsync(\n () -> {\n Exception isDead = isDead();\n if (isDead != null) {\n return Futures.immediateFailedFuture(isDead);\n }\n try {\n File[] files = Objects.requireNonNull(namespacedDirectory).listFiles(File::isFile);\n if (files != null && files.length > 0) {\n for (File f : files) {\n //noinspection ResultOfMethodCallIgnored\n f.delete();\n }\n }\n //noinspection ResultOfMethodCallIgnored\n namespacedDirectory.delete();\n cache.clear();\n } catch (Exception e) {\n return Futures.immediateFailedFuture(e);\n }\n return Futures.immediateFuture(null);\n },\n orderedIoExecutor);\n }", "class_method_signature": "SimpleStoreImpl.clear()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> clear()", "identifier": "clear", "invocations": [ "requireOpen", "submitAsync", "isDead", "immediateFailedFuture", "listFiles", "requireNonNull", "delete", "delete", "clear", "immediateFailedFuture", "immediateFuture" ], "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> clear()", "testcase": false }
{ "created": null, "fork": null, "fork_count": 4, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 158618423, "size": 876, "stargazer_count": 72, "stars": null, "updates": null, "url": "https://github.com/uber/simple-store" }
158618423_0
{ "fields": [ { "declarator": "TEST_KEY = \"test\"", "modifier": "private static final", "original_string": "private static final String TEST_KEY = \"test\";", "type": "String", "var_name": "TEST_KEY" }, { "declarator": "VALUE_ONE = new byte[] {0xA, 0xB}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_ONE = new byte[] {0xA, 0xB};", "type": "byte[]", "var_name": "VALUE_ONE" }, { "declarator": "VALUE_TWO = new byte[] {0x1, 0x2}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_TWO = new byte[] {0x1, 0x2};", "type": "byte[]", "var_name": "VALUE_TWO" }, { "declarator": "SAMPLE_SCOPE = \"myscope\"", "modifier": "private static final", "original_string": "private static final String SAMPLE_SCOPE = \"myscope\";", "type": "String", "var_name": "SAMPLE_SCOPE" }, { "declarator": "context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()", "modifier": "private", "original_string": "private Context context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();", "type": "Context", "var_name": "context" }, { "declarator": "directoryProvider = new AndroidDirectoryProvider(context)", "modifier": "private final", "original_string": "private final DirectoryProvider directoryProvider = new AndroidDirectoryProvider(context);", "type": "DirectoryProvider", "var_name": "directoryProvider" } ], "file": "simplestore/src/test/java/com/uber/simplestore/impl/SimpleStoreImplTest.java", "identifier": "SimpleStoreImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void zeroLengthWhenMissing() throws Exception {\n try (SimpleStore store = SimpleStoreFactory.create(directoryProvider, \"\")) {\n ListenableFuture<byte[]> future = store.get(TEST_KEY);\n assertThat(future.get()).hasLength(0);\n }\n }", "class_method_signature": "SimpleStoreImplTest.zeroLengthWhenMissing()", "constructor": false, "full_signature": "@Test public void zeroLengthWhenMissing()", "identifier": "zeroLengthWhenMissing", "invocations": [ "create", "get", "hasLength", "assertThat", "get" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void zeroLengthWhenMissing()", "testcase": true }
{ "fields": [ { "declarator": "OPEN = 0", "modifier": "private static final", "original_string": "private static final int OPEN = 0;", "type": "int", "var_name": "OPEN" }, { "declarator": "CLOSED = 1", "modifier": "private static final", "original_string": "private static final int CLOSED = 1;", "type": "int", "var_name": "CLOSED" }, { "declarator": "TOMBSTONED = 2", "modifier": "private static final", "original_string": "private static final int TOMBSTONED = 2;", "type": "int", "var_name": "TOMBSTONED" }, { "declarator": "EMPTY_BYTES = new byte[0]", "modifier": "private static final", "original_string": "private static final byte[] EMPTY_BYTES = new byte[0];", "type": "byte[]", "var_name": "EMPTY_BYTES" }, { "declarator": "STRING_ENCODING = StandardCharsets.UTF_16BE", "modifier": "private static final", "original_string": "private static final Charset STRING_ENCODING = StandardCharsets.UTF_16BE;", "type": "Charset", "var_name": "STRING_ENCODING" }, { "declarator": "namespace", "modifier": "private final", "original_string": "private final String namespace;", "type": "String", "var_name": "namespace" }, { "declarator": "namespacedDirectory", "modifier": "@Nullable private", "original_string": "@Nullable private File namespacedDirectory;", "type": "File", "var_name": "namespacedDirectory" }, { "declarator": "available = new AtomicInteger(OPEN)", "modifier": "", "original_string": "AtomicInteger available = new AtomicInteger(OPEN);", "type": "AtomicInteger", "var_name": "available" }, { "declarator": "cache = new HashMap<>()", "modifier": "private final", "original_string": "private final Map<String, byte[]> cache = new HashMap<>();", "type": "Map<String, byte[]>", "var_name": "cache" }, { "declarator": "orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor())", "modifier": "private final", "original_string": "private final Executor orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor());", "type": "Executor", "var_name": "orderedIoExecutor" }, { "declarator": "flush", "modifier": "@Nullable private", "original_string": "@Nullable private Exception flush;", "type": "Exception", "var_name": "flush" } ], "file": "simplestore/src/main/java/com/uber/simplestore/impl/SimpleStoreImpl.java", "identifier": "SimpleStoreImpl", "interfaces": "implements SimpleStore", "methods": [ { "class_method_signature": "SimpleStoreImpl.SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "constructor": true, "full_signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "identifier": "SimpleStoreImpl", "modifiers": "", "parameters": "(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "return": "", "signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getString(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> getString(String key)", "identifier": "getString", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> getString(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.putString(String key, @Nullable String value)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> putString(String key, @Nullable String value)", "identifier": "putString", "modifiers": "@Override public", "parameters": "(String key, @Nullable String value)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> putString(String key, @Nullable String value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.get(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> get(String key)", "identifier": "get", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> get(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.put(String key, @Nullable byte[] value)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "identifier": "put", "modifiers": "@Override public", "parameters": "(String key, @Nullable byte[] value)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.contains(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Boolean> contains(String key)", "identifier": "contains", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Boolean>", "signature": "ListenableFuture<Boolean> contains(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.remove(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> remove(String key)", "identifier": "remove", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> remove(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clear()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> clear()", "identifier": "clear", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> clear()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteAllNow()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> deleteAllNow()", "identifier": "deleteAllNow", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> deleteAllNow()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clearCache()", "constructor": false, "full_signature": " void clearCache()", "identifier": "clearCache", "modifiers": "", "parameters": "()", "return": "void", "signature": "void clearCache()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.failQueueThenRun(Exception exception, Runnable runnable)", "constructor": false, "full_signature": " void failQueueThenRun(Exception exception, Runnable runnable)", "identifier": "failQueueThenRun", "modifiers": "", "parameters": "(Exception exception, Runnable runnable)", "return": "void", "signature": "void failQueueThenRun(Exception exception, Runnable runnable)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.moveAway()", "constructor": false, "full_signature": " void moveAway()", "identifier": "moveAway", "modifiers": "", "parameters": "()", "return": "void", "signature": "void moveAway()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.recursiveDelete(File directory)", "constructor": false, "full_signature": "private static void recursiveDelete(File directory)", "identifier": "recursiveDelete", "modifiers": "private static", "parameters": "(File directory)", "return": "void", "signature": "void recursiveDelete(File directory)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.close()", "constructor": false, "full_signature": "@Override public void close()", "identifier": "close", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void close()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.requireOpen()", "constructor": false, "full_signature": "private void requireOpen()", "identifier": "requireOpen", "modifiers": "private", "parameters": "()", "return": "void", "signature": "void requireOpen()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getOrderedExecutor()", "constructor": false, "full_signature": "@VisibleForTesting Executor getOrderedExecutor()", "identifier": "getOrderedExecutor", "modifiers": "@VisibleForTesting", "parameters": "()", "return": "Executor", "signature": "Executor getOrderedExecutor()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.tombstone()", "constructor": false, "full_signature": " boolean tombstone()", "identifier": "tombstone", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean tombstone()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getNamespace()", "constructor": false, "full_signature": " String getNamespace()", "identifier": "getNamespace", "modifiers": "", "parameters": "()", "return": "String", "signature": "String getNamespace()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.openIfClosed()", "constructor": false, "full_signature": " boolean openIfClosed()", "identifier": "openIfClosed", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean openIfClosed()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.isDead()", "constructor": false, "full_signature": "@Nullable private Exception isDead()", "identifier": "isDead", "modifiers": "@Nullable private", "parameters": "()", "return": "Exception", "signature": "Exception isDead()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteFile(String key)", "constructor": false, "full_signature": "private void deleteFile(String key)", "identifier": "deleteFile", "modifiers": "private", "parameters": "(String key)", "return": "void", "signature": "void deleteFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.readFile(String key)", "constructor": false, "full_signature": "@Nullable private byte[] readFile(String key)", "identifier": "readFile", "modifiers": "@Nullable private", "parameters": "(String key)", "return": "byte[]", "signature": "byte[] readFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.writeFile(String key, byte[] value)", "constructor": false, "full_signature": "private void writeFile(String key, byte[] value)", "identifier": "writeFile", "modifiers": "private", "parameters": "(String key, byte[] value)", "return": "void", "signature": "void writeFile(String key, byte[] value)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ListenableFuture<byte[]> get(String key) {\n requireOpen();\n return Futures.submitAsync(\n () -> {\n Exception isDead = isDead();\n if (isDead != null) {\n return Futures.immediateFailedFuture(isDead);\n }\n byte[] value;\n if (cache.containsKey(key)) {\n value = cache.get(key);\n } else {\n try {\n value = readFile(key);\n } catch (IOException e) {\n return Futures.immediateFailedFuture(e);\n }\n if (value == null || value.length == 0) {\n value = EMPTY_BYTES;\n }\n cache.put(key, value);\n }\n return Futures.immediateFuture(value);\n },\n orderedIoExecutor);\n }", "class_method_signature": "SimpleStoreImpl.get(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> get(String key)", "identifier": "get", "invocations": [ "requireOpen", "submitAsync", "isDead", "immediateFailedFuture", "containsKey", "get", "readFile", "immediateFailedFuture", "put", "immediateFuture" ], "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> get(String key)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 4, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 158618423, "size": 876, "stargazer_count": 72, "stars": null, "updates": null, "url": "https://github.com/uber/simple-store" }
158618423_1
{ "fields": [ { "declarator": "TEST_KEY = \"test\"", "modifier": "private static final", "original_string": "private static final String TEST_KEY = \"test\";", "type": "String", "var_name": "TEST_KEY" }, { "declarator": "VALUE_ONE = new byte[] {0xA, 0xB}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_ONE = new byte[] {0xA, 0xB};", "type": "byte[]", "var_name": "VALUE_ONE" }, { "declarator": "VALUE_TWO = new byte[] {0x1, 0x2}", "modifier": "private static final", "original_string": "private static final byte[] VALUE_TWO = new byte[] {0x1, 0x2};", "type": "byte[]", "var_name": "VALUE_TWO" }, { "declarator": "SAMPLE_SCOPE = \"myscope\"", "modifier": "private static final", "original_string": "private static final String SAMPLE_SCOPE = \"myscope\";", "type": "String", "var_name": "SAMPLE_SCOPE" }, { "declarator": "context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext()", "modifier": "private", "original_string": "private Context context =\n InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();", "type": "Context", "var_name": "context" }, { "declarator": "directoryProvider = new AndroidDirectoryProvider(context)", "modifier": "private final", "original_string": "private final DirectoryProvider directoryProvider = new AndroidDirectoryProvider(context);", "type": "DirectoryProvider", "var_name": "directoryProvider" } ], "file": "simplestore/src/test/java/com/uber/simplestore/impl/SimpleStoreImplTest.java", "identifier": "SimpleStoreImplTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void putString() throws Exception {\n try (SimpleStore store = SimpleStoreFactory.create(directoryProvider, SAMPLE_SCOPE)) {\n store.putString(TEST_KEY, \"foo\").get();\n assertThat(store.getString(TEST_KEY).get()).isEqualTo(\"foo\");\n assertThat(store.contains(TEST_KEY).get()).isTrue();\n\n store.putString(TEST_KEY, \"\").get();\n assertThat(store.contains(TEST_KEY).get()).isFalse();\n assertThat(store.getString(TEST_KEY).get()).isEqualTo(\"\");\n\n store.putString(TEST_KEY, null).get();\n assertThat(store.contains(TEST_KEY).get()).isFalse();\n assertThat(store.getString(TEST_KEY).get()).isEqualTo(\"\");\n }\n }", "class_method_signature": "SimpleStoreImplTest.putString()", "constructor": false, "full_signature": "@Test public void putString()", "identifier": "putString", "invocations": [ "create", "get", "putString", "isEqualTo", "assertThat", "get", "getString", "isTrue", "assertThat", "get", "contains", "get", "putString", "isFalse", "assertThat", "get", "contains", "isEqualTo", "assertThat", "get", "getString", "get", "putString", "isFalse", "assertThat", "get", "contains", "isEqualTo", "assertThat", "get", "getString" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void putString()", "testcase": true }
{ "fields": [ { "declarator": "OPEN = 0", "modifier": "private static final", "original_string": "private static final int OPEN = 0;", "type": "int", "var_name": "OPEN" }, { "declarator": "CLOSED = 1", "modifier": "private static final", "original_string": "private static final int CLOSED = 1;", "type": "int", "var_name": "CLOSED" }, { "declarator": "TOMBSTONED = 2", "modifier": "private static final", "original_string": "private static final int TOMBSTONED = 2;", "type": "int", "var_name": "TOMBSTONED" }, { "declarator": "EMPTY_BYTES = new byte[0]", "modifier": "private static final", "original_string": "private static final byte[] EMPTY_BYTES = new byte[0];", "type": "byte[]", "var_name": "EMPTY_BYTES" }, { "declarator": "STRING_ENCODING = StandardCharsets.UTF_16BE", "modifier": "private static final", "original_string": "private static final Charset STRING_ENCODING = StandardCharsets.UTF_16BE;", "type": "Charset", "var_name": "STRING_ENCODING" }, { "declarator": "namespace", "modifier": "private final", "original_string": "private final String namespace;", "type": "String", "var_name": "namespace" }, { "declarator": "namespacedDirectory", "modifier": "@Nullable private", "original_string": "@Nullable private File namespacedDirectory;", "type": "File", "var_name": "namespacedDirectory" }, { "declarator": "available = new AtomicInteger(OPEN)", "modifier": "", "original_string": "AtomicInteger available = new AtomicInteger(OPEN);", "type": "AtomicInteger", "var_name": "available" }, { "declarator": "cache = new HashMap<>()", "modifier": "private final", "original_string": "private final Map<String, byte[]> cache = new HashMap<>();", "type": "Map<String, byte[]>", "var_name": "cache" }, { "declarator": "orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor())", "modifier": "private final", "original_string": "private final Executor orderedIoExecutor =\n MoreExecutors.newSequentialExecutor(SimpleStoreConfig.getIOExecutor());", "type": "Executor", "var_name": "orderedIoExecutor" }, { "declarator": "flush", "modifier": "@Nullable private", "original_string": "@Nullable private Exception flush;", "type": "Exception", "var_name": "flush" } ], "file": "simplestore/src/main/java/com/uber/simplestore/impl/SimpleStoreImpl.java", "identifier": "SimpleStoreImpl", "interfaces": "implements SimpleStore", "methods": [ { "class_method_signature": "SimpleStoreImpl.SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "constructor": true, "full_signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "identifier": "SimpleStoreImpl", "modifiers": "", "parameters": "(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "return": "", "signature": " SimpleStoreImpl(DirectoryProvider directoryProvider, String namespace, NamespaceConfig config)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getString(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> getString(String key)", "identifier": "getString", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> getString(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.putString(String key, @Nullable String value)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> putString(String key, @Nullable String value)", "identifier": "putString", "modifiers": "@Override public", "parameters": "(String key, @Nullable String value)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> putString(String key, @Nullable String value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.get(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> get(String key)", "identifier": "get", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> get(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.put(String key, @Nullable byte[] value)", "constructor": false, "full_signature": "@Override public ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "identifier": "put", "modifiers": "@Override public", "parameters": "(String key, @Nullable byte[] value)", "return": "ListenableFuture<byte[]>", "signature": "ListenableFuture<byte[]> put(String key, @Nullable byte[] value)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.contains(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Boolean> contains(String key)", "identifier": "contains", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Boolean>", "signature": "ListenableFuture<Boolean> contains(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.remove(String key)", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> remove(String key)", "identifier": "remove", "modifiers": "@Override public", "parameters": "(String key)", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> remove(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clear()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> clear()", "identifier": "clear", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> clear()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteAllNow()", "constructor": false, "full_signature": "@Override public ListenableFuture<Void> deleteAllNow()", "identifier": "deleteAllNow", "modifiers": "@Override public", "parameters": "()", "return": "ListenableFuture<Void>", "signature": "ListenableFuture<Void> deleteAllNow()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.clearCache()", "constructor": false, "full_signature": " void clearCache()", "identifier": "clearCache", "modifiers": "", "parameters": "()", "return": "void", "signature": "void clearCache()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.failQueueThenRun(Exception exception, Runnable runnable)", "constructor": false, "full_signature": " void failQueueThenRun(Exception exception, Runnable runnable)", "identifier": "failQueueThenRun", "modifiers": "", "parameters": "(Exception exception, Runnable runnable)", "return": "void", "signature": "void failQueueThenRun(Exception exception, Runnable runnable)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.moveAway()", "constructor": false, "full_signature": " void moveAway()", "identifier": "moveAway", "modifiers": "", "parameters": "()", "return": "void", "signature": "void moveAway()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.recursiveDelete(File directory)", "constructor": false, "full_signature": "private static void recursiveDelete(File directory)", "identifier": "recursiveDelete", "modifiers": "private static", "parameters": "(File directory)", "return": "void", "signature": "void recursiveDelete(File directory)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.close()", "constructor": false, "full_signature": "@Override public void close()", "identifier": "close", "modifiers": "@Override public", "parameters": "()", "return": "void", "signature": "void close()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.requireOpen()", "constructor": false, "full_signature": "private void requireOpen()", "identifier": "requireOpen", "modifiers": "private", "parameters": "()", "return": "void", "signature": "void requireOpen()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getOrderedExecutor()", "constructor": false, "full_signature": "@VisibleForTesting Executor getOrderedExecutor()", "identifier": "getOrderedExecutor", "modifiers": "@VisibleForTesting", "parameters": "()", "return": "Executor", "signature": "Executor getOrderedExecutor()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.tombstone()", "constructor": false, "full_signature": " boolean tombstone()", "identifier": "tombstone", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean tombstone()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.getNamespace()", "constructor": false, "full_signature": " String getNamespace()", "identifier": "getNamespace", "modifiers": "", "parameters": "()", "return": "String", "signature": "String getNamespace()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.openIfClosed()", "constructor": false, "full_signature": " boolean openIfClosed()", "identifier": "openIfClosed", "modifiers": "", "parameters": "()", "return": "boolean", "signature": "boolean openIfClosed()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.isDead()", "constructor": false, "full_signature": "@Nullable private Exception isDead()", "identifier": "isDead", "modifiers": "@Nullable private", "parameters": "()", "return": "Exception", "signature": "Exception isDead()", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.deleteFile(String key)", "constructor": false, "full_signature": "private void deleteFile(String key)", "identifier": "deleteFile", "modifiers": "private", "parameters": "(String key)", "return": "void", "signature": "void deleteFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.readFile(String key)", "constructor": false, "full_signature": "@Nullable private byte[] readFile(String key)", "identifier": "readFile", "modifiers": "@Nullable private", "parameters": "(String key)", "return": "byte[]", "signature": "byte[] readFile(String key)", "testcase": false }, { "class_method_signature": "SimpleStoreImpl.writeFile(String key, byte[] value)", "constructor": false, "full_signature": "private void writeFile(String key, byte[] value)", "identifier": "writeFile", "modifiers": "private", "parameters": "(String key, byte[] value)", "return": "void", "signature": "void writeFile(String key, byte[] value)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ListenableFuture<String> putString(String key, @Nullable String value) {\n byte[] bytes;\n if (value == null || value.isEmpty()) {\n bytes = null;\n } else {\n bytes = value.getBytes(STRING_ENCODING);\n }\n return Futures.transform(put(key, bytes), (b) -> value, MoreExecutors.directExecutor());\n }", "class_method_signature": "SimpleStoreImpl.putString(String key, @Nullable String value)", "constructor": false, "full_signature": "@Override public ListenableFuture<String> putString(String key, @Nullable String value)", "identifier": "putString", "invocations": [ "isEmpty", "getBytes", "transform", "put", "directExecutor" ], "modifiers": "@Override public", "parameters": "(String key, @Nullable String value)", "return": "ListenableFuture<String>", "signature": "ListenableFuture<String> putString(String key, @Nullable String value)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 4, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 158618423, "size": 876, "stargazer_count": 72, "stars": null, "updates": null, "url": "https://github.com/uber/simple-store" }
26629839_1
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testSVGGeneration() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.SVG);\n\n ResponseData responseData = new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_INPUT.getBytes(Charsets.UTF8)\n ));\n\n Assert.assertIsSVG(responseData);\n }", "class_method_signature": "PlantUMLTest.testSVGGeneration()", "constructor": false, "full_signature": "@Test public void testSVGGeneration()", "identifier": "testSVGGeneration", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "assertIsSVG" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testSVGGeneration()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_0
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testPNGGeneration() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.PNG);\n\n ResponseData responseData = new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_INPUT.getBytes(Charsets.UTF8)\n ));\n\n Assert.assertIsPNG(responseData);\n }", "class_method_signature": "PlantUMLTest.testPNGGeneration()", "constructor": false, "full_signature": "@Test public void testPNGGeneration()", "identifier": "testPNGGeneration", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "assertIsPNG" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testPNGGeneration()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_7
{ "fields": [ { "declarator": "DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\"", "modifier": "public static final", "original_string": "public static final String DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\";", "type": "String", "var_name": "DITAA_INPUT" } ], "file": "ditaa/src/test/java/org/asciidoctor/diagram/ditaa/DitaaTest.java", "identifier": "DitaaTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testPNGGeneration() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.PNG);\n \n ResponseData response = new Ditaa().generate(new Request(\n URI.create(\"/ditaa\"),\n h,\n DITAA_INPUT.getBytes(Charset.forName(\"UTF-8\"))\n ));\n\n Assert.assertIsPNG(response);\n }", "class_method_signature": "DitaaTest.testPNGGeneration()", "constructor": false, "full_signature": "@Test public void testPNGGeneration()", "identifier": "testPNGGeneration", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "forName", "assertIsPNG" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testPNGGeneration()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8;", "type": "MimeType", "var_name": "DEFAULT_CONTENT_TYPE" }, { "declarator": "DEFAULT_CHARSET = \"UTF-8\"", "modifier": "public static final", "original_string": "public static final String DEFAULT_CHARSET = \"UTF-8\";", "type": "String", "var_name": "DEFAULT_CHARSET" } ], "file": "ditaa/src/main/java/org/asciidoctor/diagram/ditaa/Ditaa.java", "identifier": "Ditaa", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "Ditaa.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }, { "class_method_signature": "Ditaa.doConvert(InputStream input, OutputStream output, ConversionOptions options)", "constructor": false, "full_signature": "private static void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "identifier": "doConvert", "modifiers": "private static", "parameters": "(InputStream input, OutputStream output, ConversionOptions options)", "return": "void", "signature": "void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "testcase": false }, { "class_method_signature": "Ditaa.convertToImage(InputStream input, ConversionOptions options)", "constructor": false, "full_signature": "private static Diagram convertToImage(InputStream input, ConversionOptions options)", "identifier": "convertToImage", "modifiers": "private static", "parameters": "(InputStream input, ConversionOptions options)", "return": "Diagram", "signature": "Diagram convertToImage(InputStream input, ConversionOptions options)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n if (!format.equals(MimeType.PNG) && !format.equals(MimeType.SVG)) {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n MimeType contentType = request.headers.getValue(HTTPHeader.CONTENT_TYPE);\n if (contentType == null) {\n contentType = DEFAULT_CONTENT_TYPE;\n }\n\n String charset = contentType.parameters.get(\"charset\");\n if (charset == null) {\n charset = DEFAULT_CHARSET;\n }\n\n java.util.List<String> options = new ArrayList();\n options.add(\"--encoding\");\n options.add(charset);\n\n if (format.equals(MimeType.SVG)) {\n options.add(\"--svg\");\n }\n\n String optionString = request.headers.getValue(HTTPHeader.OPTIONS);\n if (optionString != null) {\n options.addAll(Arrays.asList(optionString.split(\" \")));\n }\n ConversionOptions conversionOptions = ConversionOptions.parseCommandLineOptions(options.toArray(new String[0]));\n\n ByteArrayInputStream input = new ByteArrayInputStream(request.data);\n ByteArrayOutputStream output = new ByteArrayOutputStream();\n\n doConvert(input, output, conversionOptions);\n\n output.close();\n\n return new ResponseData(\n format,\n output.toByteArray()\n );\n }", "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "equals", "equals", "getValue", "get", "add", "add", "equals", "add", "getValue", "addAll", "asList", "split", "parseCommandLineOptions", "toArray", "doConvert", "close", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_6
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IOException.class)\n public void testSyntaxErrors() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.SVG);\n\n new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n \"@startuml\\nBob; sdf; foo\\n@enduml\".getBytes(Charsets.UTF8)\n ));\n }", "class_method_signature": "PlantUMLTest.testSyntaxErrors()", "constructor": false, "full_signature": "@Test(expected = IOException.class) public void testSyntaxErrors()", "identifier": "testSyntaxErrors", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes" ], "modifiers": "@Test(expected = IOException.class) public", "parameters": "()", "return": "void", "signature": "void testSyntaxErrors()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_5
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IOException.class)\n public void testBadInputFormat() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.PNG);\n h.putValue(HTTPHeader.ACCEPT, MimeType.SVG);\n\n new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_INPUT.getBytes(Charsets.UTF8)\n ));\n }", "class_method_signature": "PlantUMLTest.testBadInputFormat()", "constructor": false, "full_signature": "@Test(expected = IOException.class) public void testBadInputFormat()", "identifier": "testBadInputFormat", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes" ], "modifiers": "@Test(expected = IOException.class) public", "parameters": "()", "return": "void", "signature": "void testBadInputFormat()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_9
{ "fields": [ { "declarator": "DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\"", "modifier": "public static final", "original_string": "public static final String DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\";", "type": "String", "var_name": "DITAA_INPUT" } ], "file": "ditaa/src/test/java/org/asciidoctor/diagram/ditaa/DitaaTest.java", "identifier": "DitaaTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IOException.class)\n public void testBadInputFormat() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.PNG);\n h.putValue(HTTPHeader.ACCEPT, MimeType.PNG);\n\n new Ditaa().generate(new Request(\n URI.create(\"/ditaa\"),\n h,\n DITAA_INPUT.getBytes(Charset.forName(\"UTF-8\"))\n ));\n }", "class_method_signature": "DitaaTest.testBadInputFormat()", "constructor": false, "full_signature": "@Test(expected = IOException.class) public void testBadInputFormat()", "identifier": "testBadInputFormat", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "forName" ], "modifiers": "@Test(expected = IOException.class) public", "parameters": "()", "return": "void", "signature": "void testBadInputFormat()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8;", "type": "MimeType", "var_name": "DEFAULT_CONTENT_TYPE" }, { "declarator": "DEFAULT_CHARSET = \"UTF-8\"", "modifier": "public static final", "original_string": "public static final String DEFAULT_CHARSET = \"UTF-8\";", "type": "String", "var_name": "DEFAULT_CHARSET" } ], "file": "ditaa/src/main/java/org/asciidoctor/diagram/ditaa/Ditaa.java", "identifier": "Ditaa", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "Ditaa.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }, { "class_method_signature": "Ditaa.doConvert(InputStream input, OutputStream output, ConversionOptions options)", "constructor": false, "full_signature": "private static void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "identifier": "doConvert", "modifiers": "private static", "parameters": "(InputStream input, OutputStream output, ConversionOptions options)", "return": "void", "signature": "void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "testcase": false }, { "class_method_signature": "Ditaa.convertToImage(InputStream input, ConversionOptions options)", "constructor": false, "full_signature": "private static Diagram convertToImage(InputStream input, ConversionOptions options)", "identifier": "convertToImage", "modifiers": "private static", "parameters": "(InputStream input, ConversionOptions options)", "return": "Diagram", "signature": "Diagram convertToImage(InputStream input, ConversionOptions options)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n if (!format.equals(MimeType.PNG) && !format.equals(MimeType.SVG)) {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n MimeType contentType = request.headers.getValue(HTTPHeader.CONTENT_TYPE);\n if (contentType == null) {\n contentType = DEFAULT_CONTENT_TYPE;\n }\n\n String charset = contentType.parameters.get(\"charset\");\n if (charset == null) {\n charset = DEFAULT_CHARSET;\n }\n\n java.util.List<String> options = new ArrayList();\n options.add(\"--encoding\");\n options.add(charset);\n\n if (format.equals(MimeType.SVG)) {\n options.add(\"--svg\");\n }\n\n String optionString = request.headers.getValue(HTTPHeader.OPTIONS);\n if (optionString != null) {\n options.addAll(Arrays.asList(optionString.split(\" \")));\n }\n ConversionOptions conversionOptions = ConversionOptions.parseCommandLineOptions(options.toArray(new String[0]));\n\n ByteArrayInputStream input = new ByteArrayInputStream(request.data);\n ByteArrayOutputStream output = new ByteArrayOutputStream();\n\n doConvert(input, output, conversionOptions);\n\n output.close();\n\n return new ResponseData(\n format,\n output.toByteArray()\n );\n }", "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "equals", "equals", "getValue", "get", "add", "add", "equals", "add", "getValue", "addAll", "asList", "split", "parseCommandLineOptions", "toArray", "doConvert", "close", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_8
{ "fields": [ { "declarator": "DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\"", "modifier": "public static final", "original_string": "public static final String DITAA_INPUT =\n \"+--------+ +-------+ +-------+\\n\" +\n \"| | --+ ditaa +--> | |\\n\" +\n \"| Text | +-------+ |diagram|\\n\" +\n \"|Document| |!magic!| | |\\n\" +\n \"| {d}| | | | |\\n\" +\n \"+---+----+ +-------+ +-------+\\n\" +\n \" : ^\\n\" +\n \" | Lots of work |\\n\" +\n \" +-------------------------+\";", "type": "String", "var_name": "DITAA_INPUT" } ], "file": "ditaa/src/test/java/org/asciidoctor/diagram/ditaa/DitaaTest.java", "identifier": "DitaaTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IOException.class)\n public void testBadOutputFormat() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.parse(\"image/webp\"));\n\n new Ditaa().generate(new Request(\n URI.create(\"/ditaa\"),\n h,\n DITAA_INPUT.getBytes(Charset.forName(\"UTF-8\"))\n ));\n }", "class_method_signature": "DitaaTest.testBadOutputFormat()", "constructor": false, "full_signature": "@Test(expected = IOException.class) public void testBadOutputFormat()", "identifier": "testBadOutputFormat", "invocations": [ "putValue", "putValue", "parse", "generate", "create", "getBytes", "forName" ], "modifiers": "@Test(expected = IOException.class) public", "parameters": "()", "return": "void", "signature": "void testBadOutputFormat()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8", "modifier": "public static final", "original_string": "public static final MimeType DEFAULT_CONTENT_TYPE = MimeType.TEXT_PLAIN_UTF8;", "type": "MimeType", "var_name": "DEFAULT_CONTENT_TYPE" }, { "declarator": "DEFAULT_CHARSET = \"UTF-8\"", "modifier": "public static final", "original_string": "public static final String DEFAULT_CHARSET = \"UTF-8\";", "type": "String", "var_name": "DEFAULT_CHARSET" } ], "file": "ditaa/src/main/java/org/asciidoctor/diagram/ditaa/Ditaa.java", "identifier": "Ditaa", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "Ditaa.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }, { "class_method_signature": "Ditaa.doConvert(InputStream input, OutputStream output, ConversionOptions options)", "constructor": false, "full_signature": "private static void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "identifier": "doConvert", "modifiers": "private static", "parameters": "(InputStream input, OutputStream output, ConversionOptions options)", "return": "void", "signature": "void doConvert(InputStream input, OutputStream output, ConversionOptions options)", "testcase": false }, { "class_method_signature": "Ditaa.convertToImage(InputStream input, ConversionOptions options)", "constructor": false, "full_signature": "private static Diagram convertToImage(InputStream input, ConversionOptions options)", "identifier": "convertToImage", "modifiers": "private static", "parameters": "(InputStream input, ConversionOptions options)", "return": "Diagram", "signature": "Diagram convertToImage(InputStream input, ConversionOptions options)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n if (!format.equals(MimeType.PNG) && !format.equals(MimeType.SVG)) {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n MimeType contentType = request.headers.getValue(HTTPHeader.CONTENT_TYPE);\n if (contentType == null) {\n contentType = DEFAULT_CONTENT_TYPE;\n }\n\n String charset = contentType.parameters.get(\"charset\");\n if (charset == null) {\n charset = DEFAULT_CHARSET;\n }\n\n java.util.List<String> options = new ArrayList();\n options.add(\"--encoding\");\n options.add(charset);\n\n if (format.equals(MimeType.SVG)) {\n options.add(\"--svg\");\n }\n\n String optionString = request.headers.getValue(HTTPHeader.OPTIONS);\n if (optionString != null) {\n options.addAll(Arrays.asList(optionString.split(\" \")));\n }\n ConversionOptions conversionOptions = ConversionOptions.parseCommandLineOptions(options.toArray(new String[0]));\n\n ByteArrayInputStream input = new ByteArrayInputStream(request.data);\n ByteArrayOutputStream output = new ByteArrayOutputStream();\n\n doConvert(input, output, conversionOptions);\n\n output.close();\n\n return new ResponseData(\n format,\n output.toByteArray()\n );\n }", "class_method_signature": "Ditaa.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "equals", "equals", "getValue", "get", "add", "add", "equals", "add", "getValue", "addAll", "asList", "split", "parseCommandLineOptions", "toArray", "doConvert", "close", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_4
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IOException.class)\n public void testBadOutputFormat() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.parse(\"image/webp\"));\n\n new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_INPUT.getBytes(Charsets.UTF8)\n ));\n }", "class_method_signature": "PlantUMLTest.testBadOutputFormat()", "constructor": false, "full_signature": "@Test(expected = IOException.class) public void testBadOutputFormat()", "identifier": "testBadOutputFormat", "invocations": [ "putValue", "putValue", "parse", "generate", "create", "getBytes" ], "modifiers": "@Test(expected = IOException.class) public", "parameters": "()", "return": "void", "signature": "void testBadOutputFormat()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_3
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testMathSVGGeneration() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.SVG);\n\n ResponseData responseData = new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_MATH_INPUT.getBytes(Charsets.UTF8)\n ));\n\n Assert.assertIsSVG(responseData);\n }", "class_method_signature": "PlantUMLTest.testMathSVGGeneration()", "constructor": false, "full_signature": "@Test public void testMathSVGGeneration()", "identifier": "testMathSVGGeneration", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "assertIsSVG" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testMathSVGGeneration()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }
26629839_2
{ "fields": [ { "declarator": "PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_INPUT = \"@startuml\\nA -> B\\n@enduml\";", "type": "String", "var_name": "PLANTUML_INPUT" }, { "declarator": "PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\"", "modifier": "private static final", "original_string": "private static final String PLANTUML_MATH_INPUT = \"@startlatex\\n\\\\sum_{i=0}^{n-1} (a_i + b_i^2)\\n@endlatex\";", "type": "String", "var_name": "PLANTUML_MATH_INPUT" } ], "file": "plantuml/src/test/java/org/asciidoctor/diagram/plantuml/PlantUMLTest.java", "identifier": "PlantUMLTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void testMathPNGGeneration() throws IOException\n {\n HTTPHeaders h = new HTTPHeaders();\n h.putValue(HTTPHeader.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8);\n h.putValue(HTTPHeader.ACCEPT, MimeType.PNG);\n\n ResponseData responseData = new PlantUML().generate(new Request(\n URI.create(\"/plantuml\"),\n h,\n PLANTUML_MATH_INPUT.getBytes(Charsets.UTF8)\n ));\n\n Assert.assertIsPNG(responseData);\n }", "class_method_signature": "PlantUMLTest.testMathPNGGeneration()", "constructor": false, "full_signature": "@Test public void testMathPNGGeneration()", "identifier": "testMathPNGGeneration", "invocations": [ "putValue", "putValue", "generate", "create", "getBytes", "assertIsPNG" ], "modifiers": "@Test public", "parameters": "()", "return": "void", "signature": "void testMathPNGGeneration()", "testcase": true }
{ "fields": [ { "declarator": "DEFAULT_OUTPUT_FORMAT = MimeType.PNG", "modifier": "private static final", "original_string": "private static final MimeType DEFAULT_OUTPUT_FORMAT = MimeType.PNG;", "type": "MimeType", "var_name": "DEFAULT_OUTPUT_FORMAT" }, { "declarator": "SET_DOT_EXE", "modifier": "private static", "original_string": "private static Method SET_DOT_EXE;", "type": "Method", "var_name": "SET_DOT_EXE" }, { "declarator": "SET_DOT_EXE_INSTANCE", "modifier": "private static", "original_string": "private static Object SET_DOT_EXE_INSTANCE;", "type": "Object", "var_name": "SET_DOT_EXE_INSTANCE" } ], "file": "plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUML.java", "identifier": "PlantUML", "interfaces": "implements DiagramGenerator", "methods": [ { "class_method_signature": "PlantUML.getName()", "constructor": false, "full_signature": "@Override public String getName()", "identifier": "getName", "modifiers": "@Override public", "parameters": "()", "return": "String", "signature": "String getName()", "testcase": false }, { "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false } ], "superclass": "" }
{ "body": "@Override\n public ResponseData generate(Request request) throws IOException {\n File graphviz;\n\n String pathToGraphViz = request.headers.getValue(\"X-Graphviz\");\n if (pathToGraphViz != null) {\n File graphvizParam = new File(pathToGraphViz);\n if (graphvizParam.canExecute()) {\n graphviz = graphvizParam;\n } else {\n throw new IOException(\"GraphViz 'dot' tool at '\" + pathToGraphViz + \"' is not executable\");\n }\n } else {\n graphviz = null;\n }\n\n MimeType format = request.headers.getValue(HTTPHeader.ACCEPT);\n\n if (format == null) {\n format = DEFAULT_OUTPUT_FORMAT;\n }\n\n FileFormatOption fileFormat;\n if (format.equals(MimeType.PNG)) {\n fileFormat = new FileFormatOption(FileFormat.PNG);\n } else if (format.equals(MimeType.SVG)) {\n fileFormat = new FileFormatOption(FileFormat.SVG);\n } else if (format.equals(MimeType.TEXT_PLAIN_UTF8)) {\n fileFormat = new FileFormatOption(FileFormat.UTXT);\n } else if (format.equals(MimeType.TEXT_PLAIN)) {\n fileFormat = new FileFormatOption(FileFormat.ATXT);\n format = MimeType.parse(MimeType.TEXT_PLAIN.toString() + \";charset=\" + Charset.defaultCharset().name().toLowerCase());\n } else {\n throw new IOException(\"Unsupported output format: \" + format);\n }\n\n Option option = new Option();\n\n String plantUmlConfig = request.headers.getValue(\"X-PlantUML-Config\");\n if (plantUmlConfig != null) {\n option.initConfig(plantUmlConfig);\n }\n option.setFileFormatOption(fileFormat);\n\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n\n synchronized (this) {\n try {\n SET_DOT_EXE.invoke(SET_DOT_EXE_INSTANCE, graphviz != null ? graphviz.getAbsolutePath() : null);\n } catch (IllegalAccessException | InvocationTargetException e) {\n throw new IOException(e);\n }\n\n BlockUmlBuilder builder = new BlockUmlBuilder(\n option.getConfig(),\n \"UTF-8\",\n Defines.createEmpty(),\n new StringReader(request.asString()),\n FileSystem.getInstance().getCurrentDir(),\n \"<input>\"\n );\n List<BlockUml> blocks = builder.getBlockUmls();\n\n if (blocks.size() == 0) {\n throw new IOException(\"No @startuml found\");\n } else {\n for (BlockUml b : blocks) {\n Diagram system = b.getDiagram();\n if (system instanceof PSystemError) {\n system.exportDiagram(byteArrayOutputStream, 0, new FileFormatOption(FileFormat.UTXT));\n String error = new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);\n throw new IOException(error);\n }\n\n if (system.getNbImages() > 0) {\n system.exportDiagram(byteArrayOutputStream, 0, fileFormat);\n break;\n }\n }\n }\n }\n\n return new ResponseData(\n format,\n byteArrayOutputStream.toByteArray()\n );\n }", "class_method_signature": "PlantUML.generate(Request request)", "constructor": false, "full_signature": "@Override public ResponseData generate(Request request)", "identifier": "generate", "invocations": [ "getValue", "canExecute", "getValue", "equals", "equals", "equals", "equals", "parse", "toString", "toLowerCase", "name", "defaultCharset", "getValue", "initConfig", "setFileFormatOption", "invoke", "getAbsolutePath", "getConfig", "createEmpty", "asString", "getCurrentDir", "getInstance", "getBlockUmls", "size", "getDiagram", "exportDiagram", "toByteArray", "getNbImages", "exportDiagram", "toByteArray" ], "modifiers": "@Override public", "parameters": "(Request request)", "return": "ResponseData", "signature": "ResponseData generate(Request request)", "testcase": false }
{ "created": null, "fork": null, "fork_count": 6, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 26629839, "size": 44606, "stargazer_count": 7, "stars": null, "updates": null, "url": "https://github.com/asciidoctor/asciidoctor-diagram-java" }